mirror of
https://github.com/flynx/pWiki.git
synced 2025-10-28 09:30:07 +00:00
added .remove(..) / .clear(..) backup methods...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
c63bba1d24
commit
f39943affb
32
pwiki2.js
32
pwiki2.js
@ -1222,7 +1222,7 @@ module.backup = {
|
||||
if(typeof(sub) == 'object'){
|
||||
options = sub
|
||||
sub = '*' }
|
||||
var {index, backup} = getOpts(options)
|
||||
var {backup} = getOpts(options)
|
||||
|
||||
// handle local/global backups...
|
||||
var full = backup[0] == '/'
|
||||
@ -1233,18 +1233,32 @@ module.backup = {
|
||||
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)) }) },
|
||||
return fs.existsSync(base) ?
|
||||
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(..)
|
||||
// ...
|
||||
|
||||
remove: async function(base, version, options){
|
||||
var {backup, verbose} = getOpts(options)
|
||||
var target =
|
||||
(version == '*' || version == '**') ?
|
||||
module.path.join(base, backup)
|
||||
: module.path.join(base, backup, version)
|
||||
if(fs.existsSync(target)){
|
||||
verbose
|
||||
&& console.log(`.remove(..): removing:`, target)
|
||||
await fs.promises.rm(target, {recursive: true})
|
||||
return target } },
|
||||
clear: async function(base, options){
|
||||
return await this.remove(base, '*', options) }
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user