Skip to content
This repository has been archived by the owner on Apr 6, 2021. It is now read-only.

add recursive copy function #3

Open
fjakobs opened this issue May 5, 2012 · 4 comments
Open

add recursive copy function #3

fjakobs opened this issue May 5, 2012 · 4 comments

Comments

@fjakobs
Copy link
Contributor

fjakobs commented May 5, 2012

No description provided.

@ghost ghost assigned creationix May 5, 2012
@creationix
Copy link
Contributor

What should be the behavior on the various error conditions? Since this is a fairly complex operation many assumptions or options have to be coded.

Some problems include:

  • A file or directory in the source tree is not readable
  • A destination file or directory is not writable.
  • All or part of the destination files already exist.

Should the whole operation fail early on error, should it check for possible errors before starting real work, should it ignore errors as best and continue working where possible?

Also, not errors, but what if the destination is a sub-folder of the source tree? Care needs to be taken to ensure the newly created files aren't copied again recursively.

@fjakobs
Copy link
Contributor Author

fjakobs commented May 8, 2012

jsDAV does the following: "copy: This method must work recursively and delete the destination if it exists"

this would get rid of most of the edge cases. An alternative could also be to fail if the destination folder exists. Then the client needs to resolve this conflict.

If the destination is a sub-folder of the source tree we should also return an error.

@creationix
Copy link
Contributor

Sounds good, we can error out if the destination folder exists or is a subfolder. That still leaves the edge case of when a source file or folder is not readable. Should we stop of first error, continue past any errors, or check the entire tree in a pre-flight step? (and even with a pre-flight check, things can change after the fact, so errors are still possible, but much less likely)

@fjakobs
Copy link
Contributor Author

fjakobs commented May 9, 2012

Sounds good. My suggestion:

  1. check if destination exists or is a subfolder of the source. If so return an error.
  2. copy the source to a temp dir.
  3. if there is an error remove the temp dir and report it
  4. once we copied successfully move the temp dir to the destination
    4.1 if this also fails because the target has been added while copying we perform 2.

We could add the prefilght check as an option to step 1. For cloud9 it is not likely to cause any problems without the preflight.

@fjakobs fjakobs reopened this May 10, 2012
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants