-
-
Notifications
You must be signed in to change notification settings - Fork 645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add high-level Copy and Move commands #37
Comments
Sounds like a good idea. Can you specify more details how they would work? What would the method signatures look like?
I think move file is similar to rename? |
Hi, The signatures look reasonable. I guess the only thing that may be added somewhere is the FtpListOption as that would affect how files/folders are discovered. In terms of how they would work.... In my head they would be an all or nothing operation without any form of transactional support. So if you were moving a directory tree and ran into issues along the way the method would return false and throw some form of exception. Move file is not totally similair to rename as move might change location and name of the file. |
Approximately how will these commands work? I need some more info before I can begin implementing this.
|
@natiki - Can you check if the above pseudo code looks ok so I can begin implementing it? |
@hgupta9 Have not forgotten about this. Will let you know in a couple of days. |
Can you respond please? |
Apologies for the delay.... You should have a look at the FTP commands RNFR and RNTO as these will allow you to do the above operations on the server without the need to download the files and upload them again. Below is an example of me moving a folder /Blah to /Blah3
I would guess you could do all operations this way even copy as long as you generated a new name to avoid name conflicts. |
That's amazing! I will look into supporting these FTP commands. |
I just checked the code and Rename does exactly that. It first executes RNFR and if it succeeds it executes RNTO. It can be used as a backend for MoveFile and MoveDirectory. However for copying we will first have to download and re-upload. |
Well for copy you could do the same as the above if you generate a temporary top level name and then change it to what it needs to be etc. as long as there is no conflict. |
But how would we preserve the source file/dir if we have moved it to a new path? |
Have a look at FXP https://en.wikipedia.org/wiki/File_eXchange_Protocol. If the server supports it then you don't have to download first. |
Its complicated but sounds decent enough once implemented. To add to the fact that most servers have it disabled .. "As a result of this, FTP server software often has FXP disabled by default." I think downloading and uploading seems like a simple enough solution until this FXP system can be implemented. |
Implemented MoveFile() and MoveDirectory() in trunk. Advantages over Rename() include :
|
Will you implement FXP? |
@sergeu90 To add to the fact that most servers have FXP disabled .. "As a result of this, FTP server software often has FXP disabled by default." |
Moving files between the directories in server was exactly what i needed. I couldn't find it in the examples, searched it on google and got me here. Thanks a lot |
Hi,
Would you consider adding Copy and Move primitives for both File and Directory? I realise these are not core FTP commands but would make great additions.
The overarching simplification being that as these are compound actions and would require a number of commands to be executed against the FTP server, if something failed half way through then the command returns FALSE and gives up.
The text was updated successfully, but these errors were encountered: