Skip to content

Commit

Permalink
Updates script to write existing contents when switching to Dropbox
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmerfield committed Dec 16, 2019
1 parent 5dfda24 commit 84a0965
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions app/clients/dropbox/routes/writeExistingContents.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
});
}

Expand Down

0 comments on commit 84a0965

Please sign in to comment.