| | |
| | | total++; |
| | | } |
| | | }); |
| | | /* |
| | | |
| | | var remove = []; |
| | | Object.keys(dst.entries).forEach(function (key) { |
| | | var e = dst.entries[key]; |
| | |
| | | total++; |
| | | } |
| | | }); |
| | | */ |
| | | |
| | | if (!total) { |
| | | return callback(null); |
| | | } |
| | |
| | | } |
| | | }); |
| | | |
| | | return; |
| | | |
| | | // sort paths in descending order so files are deleted before their |
| | | // parent directories |
| | | remove.sort().reverse().forEach(function(path) { |
| | | var info = dst.entries[path]; |
| | | if (dst.type === 'local') { |
| | | CLOUDFS.removeLocalEntry(path, info, done); |
| | | CLOUDFS.removeLocalEntry(path, done); |
| | | } else { |
| | | CLOUDFS.removeRemoteEntry(path, info, done); |
| | | CLOUDFS.removeRemoteEntry(mount, dst.entries[path], done); |
| | | } |
| | | }); |
| | | }, |
| | |
| | | callback(e); |
| | | }) |
| | | } |
| | | }, |
| | | // remove local and remote files |
| | | removeLocalEntry: function(path, callback) { |
| | | try { |
| | | var lookup = FS.lookupPath(path); |
| | | var stat = FS.stat(path); |
| | | |
| | | if (FS.isDir(stat.mode)) { |
| | | FS.rmdir(path); |
| | | } else if (FS.isFile(stat.mode)) { |
| | | FS.unlink(path); |
| | | } |
| | | } catch (e) { |
| | | return callback(e); |
| | | } |
| | | |
| | | callback(null); |
| | | }, |
| | | removeRemoteEntry: function(mount, pathinfo, callback) { |
| | | if (pathinfo.type == 'file') { |
| | | mount.opts.provider.rm(mount.opts.cloud, pathinfo, function() { |
| | | callback(null); |
| | | }, |
| | | function(e) { |
| | | callback(e); |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | }; |