Skip to content
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

.Copy & .CopySync #115

Closed
devildeveloper opened this issue Feb 23, 2015 · 9 comments
Closed

.Copy & .CopySync #115

devildeveloper opened this issue Feb 23, 2015 · 9 comments

Comments

@devildeveloper
Copy link

Hi, I'm working on this project: https://github.com/devildeveloper/BlackMeza/blob/master/index.js.
I have the following problem: .copy method does not work. The copySync method only works if I did not send the callback, otherwise generates only the structure of folders.

I'm working with Osx Yosemite

@jprichardson
Copy link
Owner

Can you produce any code to reproduce the problem? I'm unable to reproduce it. Thanks.

@felicienfrancois
Copy link

I have the same issue.
Callback is never called for copy and the copy hang.

Reproduced with a simple directory copy on windows

@felicienfrancois
Copy link

I think I have found the issue,

in copy.js, line 40:

if (stats.isDirectory()) {
    var parts = dest.split(path.sep)
    parts.pop()
    dir = parts.join(path.sep)
}

This code does not work on windows if dest argument uses slash instead of anti-slash (which is supported by all fs libraries)
The pathes should not be manipulated using string functions but using path utils:

if (stats.isDirectory()) {
    dir = path.resolve(dest, "..");
}

Do you want me to make a pull request ?

@felicienfrancois
Copy link

that's maybe not the only issue because it also fail with anti-slash pathes and when the dest directory does not exists (not passing the stats.isDirectory() test)

@jprichardson
Copy link
Owner

Do you want me to make a pull request ?

Yes, would love any help that you're willing to offer :)

@felicienfrancois
Copy link

Just made a pull request for the issue I found in my previous comment.

Regarding this issue, I'll try to reproduce and enquire soon.
Anyway, it should should be made clearer:

  • Copysync not working is not a bug, this is an understanding issue or a documentation issue as sync methods does not accept callback. When passing a callback function, it is taken has a filter option.
    This means that the function may be called several times and the result will depends on the return.
  • The issue with async Copy function was the following: it created the folder structure and never called the callback function.

@jprichardson
Copy link
Owner

@felicienfrancois are you using the latest 0.16.5?

@felicienfrancois
Copy link

I'm was using either 0.14 or 0.16.4. When I get the issue it was reproductible at 100%.

But I tried to reproduce it later and I never succeed, even on the same computer, with the same setup, same version of fs-extra and same revision of my code.

I no longer have the issue with 0.16.5 but I cannot tell you if the issue is fixed as I'm not able to reproduce it with older version :S.

I don't know what can be the cause but parallel copy is a bit hazardous. It could creates deadlocks with file system locks or whatever problems due to doing several operation in parallel in the same place.

Is there really a lot of performance difference between parralel and sequencial copy (I mean async but sequential) ?

On top of that, in async mode, a timeout option would be welcome to handle any possible error (coming from fs-extra or any underlying native or not native modules).

@jprichardson jprichardson modified the milestone: 1.0 Jul 2, 2015
@RyanZim
Copy link
Collaborator

RyanZim commented Oct 26, 2016

@jprichardson This issue is so old, shouldn't we just close it and see if anyone else reports it later?

@RyanZim RyanZim removed this from the 1.0.0 milestone Oct 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants