From c63bba1d2496fa31c0f04dc7f48e6d2eb3cb515c Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Tue, 2 Aug 2022 01:31:49 +0300 Subject: [PATCH] notes and minor tweaks... Signed-off-by: Alex A. Naanou --- pwiki2.js | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/pwiki2.js b/pwiki2.js index 09cc848..0fd849c 100755 --- a/pwiki2.js +++ b/pwiki2.js @@ -762,11 +762,15 @@ module.localStorageNestedStore = { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// +// XXX structure is not final... +// - need to split each adapter into modules... +// - should the media handler api be merged with store??? +// - how do we handle config??? var fs = require('fs') var glob = require('glob') - var FILESTORE_OPTIONS = { index: '.index', backup: '/.backup', @@ -778,7 +782,8 @@ var FILESTORE_OPTIONS = { verbose: true, } -var getOpts = function(opts){ +var getOpts = +function(opts){ return { ...FILESTORE_OPTIONS, ...(opts ?? {}), @@ -980,9 +985,18 @@ async function(base, options){ continue } } } }) } +// XXX backup metadata... +// - date +// - reason +// - refs... +// XXX set hidden attribute on backup dir... var backup = module.backup = { // XXX backup config??? + //index: '.index', + //base: '/.backup', + //cleanBackup: true, + //verbose: true, // // .create([, ]) @@ -1209,8 +1223,28 @@ module.backup = { options = sub sub = '*' } var {index, backup} = getOpts(options) - // XXX - }, + + // handle local/global backups... + var full = backup[0] == '/' + base = full ? + module.path.join(base, backup) + : module.path.join(base, module.path.dirname(sub), backup) + sub = full ? + sub + : module.path.basename(sub) + + return fs.promises.readdir(base) + .iter() + .filter(function(version){ + return (sub == '*' || sub == '**') + || fs.existsSync( + module.path.join(base, version, sub)) }) }, + + // XXX do we need methods lile: + // .remove(base, version, ..) + // .clear(base, ..) + // .pack(..) + // ... }