Skip to content
Permalink
Browse files

Updates dropbox sync script

  • Loading branch information
davidmerfield committed Nov 24, 2019
1 parent 6a19549 commit 6a851874fb5ac3fe1d3c37550741ad293322460a
Showing with 39 additions and 16 deletions.
  1. +39 −16 scripts/dropbox/sync.js
@@ -1,21 +1,44 @@
var DropboxSync = require("../../app/clients/dropbox/sync");
var sync = require("../../app/clients/dropbox/sync");
var get = require("../get/blog");
var each = require("../each/blog");
var async = require("async");
console.warn("Warning: this uses an internal method of the Dropbox client.");
console.log('Consider debugging with "export DEBUG=clients:dropbox*"');

get(process.argv[2], function(err, user, blog) {
if (err) throw err;
if (process.argv[2]) {
get(process.argv[2], function(err, user, blog) {
if (err) throw err;
sync(blog, function(err) {
if (err) throw err;
process.exit();
});
});
} else {
var blogs = [];

console.log(
"Warning, this uses internal functions of Dropbox client. Syncing blog...",
blog.handle
);
each(
function(user, blog, next) {
if (blog.client === "dropbox") blogs.push(blog);
next();
},
function() {
// Sort blogs to sync least recently synced first
blogs.sort(function(a, b) {
return a.cacheID > b.cacheID ? 1 : -1;
});

console.log(
'Consider running dropbox client in debug mode: "export DEBUG=clients:dropbox*"'
async.eachSeries(
blogs,
function(blog, next) {
console.log("Syncing", blog.title, blog.id, new Date(blog.cacheID));
sync(blog, next);
},
function(err) {
if (err) throw err;
console.log("Done!");
process.exit();
}
);
}
);

DropboxSync(blog, function(err) {
if (err) throw err;

console.log("Synced blog!");
});
});
}

0 comments on commit 6a85187

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