ncp icon indicating copy to clipboard operation
ncp copied to clipboard

Clobber mode issue

Open redgecombe opened this issue 11 years ago • 1 comments
trafficstars

There seems to be an issue copying a directory over another directory using clobber mode. I am finding that intermittently the completion callback is never triggered.

I did a little digging and saw that the "running" count becomes negative in my case.

I think the issue is in the onFile function here:

      if(clobber) {
        rmFile(target, function () {
          copyFile(file, target);
        });
      }
      if (modified) {
        var stat = dereference ? fs.stat : fs.lstat;
        stat(target, function(err, stats) {
            //if souce modified time greater to target modified time copy file
            if (file.mtime.getTime()>stats.mtime.getTime())
                copyFile(file, target);
            else return cb();
        });
      }

If clobber is true, there can be two calls to copyFile, eventually causing two calls to cb, resulting in the started/finished/running counts getting out of sync. I think this is related to this change: https://github.com/AvianFlu/ncp/commit/85cd50a5736f009cb2b50ac2a090542eb27b7e9c

Thanks

redgecombe avatar Oct 08 '14 21:10 redgecombe

Fixed in #68.

coderaiser avatar Nov 10 '14 13:11 coderaiser