Giter VIP home page Giter VIP logo

Comments (17)

robinrodricks avatar robinrodricks commented on May 22, 2024

Sounds like a good idea. Can you specify more details how they would work? What would the method signatures look like?

  • CopyFile(string src, string dest, bool overwrite = true)
  • CopyDirectory(string src, string dest, bool overwrite = true)
  • MoveFile(string src, string dest, bool overwrite = true)
  • MoveDirectory(string src, string dest, bool overwrite = true)

I think move file is similar to rename?

from fluentftp.

natiki avatar natiki commented on May 22, 2024

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.

from fluentftp.

robinrodricks avatar robinrodricks commented on May 22, 2024

Approximately how will these commands work? I need some more info before I can begin implementing this.

  • CopyFile
    • download file to disk/stream (direct server to server is not possible with FTP, only SFTP can do that)
    • upload file to server
  • CopyDirectory
    • download entire folder recursively to disk (not into memory since it can be too big???)
    • upload directory to server, file by file
  • MoveFile
    • same as Rename? can Rename be used to move a file from X to Y?
    • if you can do some tests with Rename to check its behavior it would speed up the implementation of this feature
  • MoveDirectory
    • same as Rename? can Rename be used to move an entire folder?
    • if you can do some tests with Rename to check its behavior it would speed up the implementation of this feature

from fluentftp.

robinrodricks avatar robinrodricks commented on May 22, 2024

@natiki - Can you check if the above pseudo code looks ok so I can begin implementing it?

from fluentftp.

natiki avatar natiki commented on May 22, 2024

@hgupta9 Have not forgotten about this. Will let you know in a couple of days.

from fluentftp.

robinrodricks avatar robinrodricks commented on May 22, 2024

Can you respond please?

from fluentftp.

natiki avatar natiki commented on May 22, 2024

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

[08:39:51] [R] MKD /Blah3
[08:39:51] [R] 257-"/Blah3" : The directory was successfully created
[08:39:51] [R] 257 224130 Kbytes used (10%) - authorized: 2097152 Kb
[08:40:13] [R] CWD /Blah
[08:40:13] [R] 250 OK. Current directory is /Blah
[08:40:13] [R] PWD
[08:40:13] [R] 257 "/Blah" is your current location
[08:40:13] [R] CWD /Blah3
[08:40:13] [R] 250 OK. Current directory is /Blah3
[08:40:13] [R] PWD
[08:40:13] [R] 257 "/Blah3" is your current location
[08:40:13] [R] CWD /
[08:40:13] [R] 250 OK. Current directory is /
[08:40:13] [R] PWD
[08:40:13] [R] 257 "/" is your current location
[08:40:13] [R] PASV
[08:40:13] [R] 227 Entering Passive Mode (118,127,42,204,117,178)
[08:40:13] [R] Opening data connection IP: 118.127.42.204 PORT: 30130
[08:40:13] [R] MLSD
[08:40:13] [R] 150 Accepted data connection
[08:40:13] [R] 226-Options: -a -l 
[08:40:13] [R] 226 6 matches total
[08:40:13] [R] List Complete: 659 bytes in 0.04 seconds (0.6 KB/s)
[08:40:13] [R] RNFR /Blah/sample.pas.txt
[08:40:13] [R] 350 RNFR accepted - file exists, ready for destination
[08:40:13] [R] RNTO /Blah3/sample.pas.txt
[08:40:13] [R] 250 File successfully renamed or moved
[08:40:13] [R] RNFR /Blah/template.info
[08:40:13] [R] 350 RNFR accepted - file exists, ready for destination
[08:40:13] [R] RNTO /Blah3/template.info
[08:40:13] [R] 250 File successfully renamed or moved
[08:40:13] [R] PASV
[08:40:13] [R] 227 Entering Passive Mode (118,127,42,204,133,106)
[08:40:13] [R] Opening data connection IP: 118.127.42.204 PORT: 34154
[08:40:13] [R] MLSD
[08:40:13] [R] 150 Accepted data connection
[08:40:13] [R] 226-Options: -a -l 
[08:40:13] [R] 226 6 matches total
[08:40:13] [R] List Complete: 659 bytes in 0.04 seconds (0.6 KB/s)
[08:40:13] Transfer queue completed
[08:40:13] Transferred 0 Files (0 bytes) in 0.21 seconds (0.0 KB/s)

I would guess you could do all operations this way even copy as long as you generated a new name to avoid name conflicts.

from fluentftp.

robinrodricks avatar robinrodricks commented on May 22, 2024

That's amazing! I will look into supporting these FTP commands.

from fluentftp.

robinrodricks avatar robinrodricks commented on May 22, 2024

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.

from fluentftp.

natiki avatar natiki commented on May 22, 2024

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.

from fluentftp.

robinrodricks avatar robinrodricks commented on May 22, 2024

But how would we preserve the source file/dir if we have moved it to a new path?

from fluentftp.

natiki avatar natiki commented on May 22, 2024

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.

from fluentftp.

robinrodricks avatar robinrodricks commented on May 22, 2024

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.

from fluentftp.

robinrodricks avatar robinrodricks commented on May 22, 2024

Implemented MoveFile() and MoveDirectory() in trunk. Advantages over Rename() include :

  • In Skip mode, if the dest already exists the operation is skipped
  • In Overwrite mode, if the dest already exists it is deleted first, and then the Rename() is performed

from fluentftp.

sergeushenecz avatar sergeushenecz commented on May 22, 2024

Will you implement FXP?

from fluentftp.

robinrodricks avatar robinrodricks commented on May 22, 2024

@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."

from fluentftp.

Koxbox360 avatar Koxbox360 commented on May 22, 2024

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

from fluentftp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.