backup target: create snapshot and cache files per target

snapshot file tracks the snapshot directory. when app gets deleted,
the cleaner will remove the upstream snapshot directory when it runs.

cache files are used in rsync logic to track what was uploading into
snapshot in the previous run without needing to rescan upstream.
This commit is contained in:
Girish Ramakrishnan
2025-07-30 11:19:07 +02:00
parent b971f2ab22
commit ae3a34287a
9 changed files with 87 additions and 71 deletions
+3 -4
View File
@@ -6,7 +6,6 @@ const assert = require('assert'),
debug = require('debug')('box:syncer'),
fs = require('fs'),
path = require('path'),
paths = require('./paths.js'),
safe = require('safetydance');
exports = module.exports = {
@@ -63,14 +62,14 @@ function ISFILE(x) {
return (x & fs.constants.S_IFREG) === fs.constants.S_IFREG;
}
async function sync(dataLayout) {
async function sync(dataLayout, options) {
assert(dataLayout instanceof DataLayout, 'Expecting dataLayout to be a DataLayout');
assert.strictEqual(typeof options, 'object');
const addQueue = [], delQueue = []; // separate queues. we have to process the del first and then the add
let curCacheIndex = 0;
const cacheFile = path.join(paths.BACKUP_INFO_DIR, dataLayout.getBasename() + '.sync.cache'),
newCacheFile = path.join(paths.BACKUP_INFO_DIR, dataLayout.getBasename() + '.sync.cache.new');
const cacheFile = options.cacheFile, newCacheFile = `${options.cacheFile}.new`;
let cache = [];