Skip to content
Permalink
Browse files

Updates script to write existing contents when switching to Dropbox

  • Loading branch information
davidmerfield committed Dec 16, 2019
1 parent 5dfda24 commit 84a09658b4919d2b3e591ec92f834a6ea0aff8a2
Showing with 5 additions and 8 deletions.
  1. +5 −8 app/clients/dropbox/routes/writeExistingContents.js
@@ -62,28 +62,25 @@ function ensureLowerCase (directory, name, callback){

if (name === name.toLowerCase()) return callback(null, name);

if (directory !== directory.toLowerCase()) return callback(new Error('Directory must be lowercase'));

currentPath = join(directory, name);

parsedPath = Path.parse(currentPath.toLowerCase());
parsedPath = Path.parse(currentPath);

names = [
name.toLowerCase(),
parsedPath.name + ' (conflict)' + parsedPath.ext,
parsedPath.name.toLowerCase() + ' (conflict)' + parsedPath.ext.toLowerCase(),
];

for (var i=1;i<100;i++) {
names.push(parsedPath.name + ' (conflict ' + i + ')' + parsedPath.ext);
names.push(parsedPath.name.toLowerCase() + ' (conflict ' + i + ')' + parsedPath.ext.toLowerCase());
}

async.eachSeries(names, function(paths, next){
async.eachSeries(names, function(name, next){
fs.move(currentPath, join(directory, name), function(err){
if (err) return next();
callback(null, name);
});
}, function(){
callback(new Error("Ran out of candidates to lowercase path"));
callback(new Error("Ran out of candidates to lowercase path: " + currentPath));
});
}

0 comments on commit 84a0965

Please sign in to comment.
You can’t perform that action at this time.