Skip to content
Permalink
Browse files

Updates script to remove case-conflicted files

  • Loading branch information
davidmerfield committed Dec 16, 2019
1 parent 1c434c7 commit 66670629f558125f88ea33ed8f8993e77634f209
Showing with 47 additions and 0 deletions.
  1. +47 −0 scripts/dropbox/remove-case-conflicted-files.js
@@ -0,0 +1,47 @@
var get = require('../get/blog');
var localPath = require('helper').localPath;
var yesno = require('yesno');
var async = require('async');
var fs = require('fs-extra');
var join = require('path').join;
var pathsToRemove = [];
get(process.argv[2], function(err, user, blog) {
if (err) throw err;
if (blog.client !== 'dropbox') throw new Error('Not connected to Dropbox');
var localFolder = localPath(blog.id, '/');
walk('/', function(err) {
if (err) throw err;
if (!pathsToRemove.length) {
console.log('Done!');
return process.exit();
}
console.log(pathsToRemove);
yesno.ask('Remove paths? (y/n)', false, function(ok) {
if (!ok) return process.exit();
async.eachSeries(pathsToRemove, fs.remove, function(err) {
if (err) throw err;
console.log('Done!');
process.exit();
});
});
});

function walk(path, callback) {
console.log("iterating", path);
async.eachSeries(
fs.readdirSync(localFolder + path),
function handleItem(name, next) {
console.log(". ", join(localFolder, path, name));
var stat = fs.statSync(join(localFolder, path, name));
if (name !== name.toLowerCase() && fs.existsSync(join(localFolder, path, name).toLowerCase())) {
pathsToRemove.push(join(localFolder, path, name));
}
if (stat.isDirectory()) {
return walk(join(path, name), next);
}
next();
},
callback
);
}
});

0 comments on commit 6667062

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