MCPcopy
hub / github.com/CodeboxIDE/codebox / doSync

Function doSync

client/core/localfs.js:399–423  ·  view source on GitHub ↗
(fp)

Source from the content-addressed store, hash-verified

397 var box = require("core/box");
398
399 var doSync = function(fp) {
400 var path = fp.path();
401 if (isIgnoredFile(path)) return Q();
402
403 logger.log("sync:box->local:", path);
404
405 if (fp.isDirectory()) {
406 // Create the directory
407 return createDirectory(path).then(function() {
408 // List subfiles
409 return fp.listdir();
410 }).then(function(files) {
411 // Recursively sync files and directory
412 return Q.all(_.map(files, function(f) {
413 return doSync(f);
414 }));
415 });
416 } else {
417 // Read file content
418 return fp.read().then(function(content) {
419 // Write file content
420 return writeFile(path, content);
421 });
422 }
423 };
424 return operations.start("files.sync.download", function(op) {
425 logger.warn("Start sync: box->local");
426

Callers 1

localfs.jsFile · 0.85

Calls 2

isIgnoredFileFunction · 0.85
QFunction · 0.85

Tested by

no test coverage detected