Home > Back-end >  IdFTPServer OnReNameFile process what to use?
IdFTPServer OnReNameFile process what to use?

Time:10-02

Under a TFTPServer encapsulation IdFTPServer class, IdFTPServer OnReNameFile process inside can back to the parameter estimation only ASender, this process at the moment, I cannot use under Delphi7 + 7, the code is as follows (also added a part of yourself)
Procedure TFTPServer. IdFTPServer1RenameFile (ASender: TIdFTPServerThread;
Const ARenameFromFile ARenameToFile: string);
Var
AFrom, ATo, Cur: string;
Attri: Integer;
The begin
//ASender. Connection. SendCmd (' 500 refused to modify ');
//exit;
AFrom:=ARenameFromFile;
ATo:=ARenameToFile;
If (ASender. CurrentDir<> '/') and (Length (ASender CurrentDir) & gt; 0) then
The begin
Cur:=ASender. CurrentDir;
If a Cur [Length (Cur)] <> '/' then Cur: Cur +='/';
AFrom:=Cur + AFrom;
ATo:=Cur + ATo;
The end;
//check whether repeated
Attri:=FileGetAttr (TransLatePath (AFrom, ASender. HomeDir));
If Attri<> 1 then
The begin
ASender. Connection. SendCmd (' 553 file (folder) name repetition ');
The exit;
The end;
Try
If not MoveFile (pchar (TransLatePath (AFrom, ASender. HomeDir)), pchar (TransLatePath (ATo, ASender. HomeDir))) then
RaiseLastOSError;
Except,
On e: the Exception do
The begin
If Assigned (FOnFtpNotifyEvent) then
OnFtpNotifyEvent (Now, ASender Connection. Socket. Binding. The PeerIP, 'renaming files [' + Utf8ToAnsi (AFrom) +'] failure, the reason is' + e.M essage);
The Exit;
The end;
The end;
If Assigned (FOnFtpNotifyEvent) then
OnFtpNotifyEvent (Now, ASender Connection. Socket. Binding. The PeerIP, 'renaming files [' + Utf8ToAnsi (AFrom) +'] to [' + Utf8ToAnsi (ATo) + '] ');
The end;
Questions as follows:
1, source code in the rename files (folders), if there is a repeat, the need to test whether repeated, otherwise the ERROR, is normal for the first time, but from the second, the nuptial resource manager crash, when waiting for a period of time, SOCKET program report ERROR # 10093 ERROR, this time a resource manager will correct tip file name repetition can't modify,
2, if the modified file (folder) name does not repeat, actually modify the name will be immediately successful, but at this moment the resource manager crash, after waiting for a period of time, the program report OCKET ERROR # 10093 ERROR, then the resource manager without permission operation failure (the actual) success, refresh the resource manager, the new name will be displayed,
Can you tell me OnRenameFile the process how to use?

CodePudding user response:

About file name repetition because SendCmd calls the method GetResponse was blocked, so the direct call WriteLn, can avoid the problem 1, 2 how to solve the problem? Seems to have appeared in the jam?

CodePudding user response:

It was not through ASender return status, so that the client wait for receipt crash, problem solution is after the MoveFile success of 2, call ASender. Connection. The WriteLn (" 200 OK "); Through response code 200 to inform the client to modify success, at that time, the resource manager change the file name will be immediately successful, therefore OnRenameFile inside, no matter whether success or failure of operation, is must return receipt by ASender client information,

CodePudding user response:

There is another problem:
1, if it is not allowed to delete files, the resource manager will be prompted to refuse to delete, but after the prompt, can no longer continue to use, the resource manager report 250200 errors,
2, if do not allow the new folder, not allowed to upload files, error ditto,

Excuse me, is what reason,
  • Related