From d001f27dc7e453e6d17c030b7cf4735652da53b7 Mon Sep 17 00:00:00 2001 From: simatec Date: Sun, 10 Dec 2023 21:38:10 +0100 Subject: [PATCH] (simatec) Copypath check added --- README.md | 1 + lib/scripts/60-cifs.js | 37 +++++++++++++++++++------------------ 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index f17000b7..9b6ff813 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ When the adapter crashes or another Code error happens, this error message that ### **WORK IN PROGRESS** * (simatec) Gotify Notication added * (simatec) dependencies updated +* (simatec) Copypath check added ### 2.9.5 (2023-11-29) * (simatec) dependencies updated diff --git a/lib/scripts/60-cifs.js b/lib/scripts/60-cifs.js index da430807..26edd6e4 100644 --- a/lib/scripts/60-cifs.js +++ b/lib/scripts/60-cifs.js @@ -95,28 +95,29 @@ function command(options, log, callback) { } log.debug(`used copy path: ${dir}`); - //if (fs.existsSync(options.dir)) { - //copyFiles(options.dir, fileNames, log, options.context.errors, err => { if (fs.existsSync(dir)) { - copyFiles(dir, fileNames, log, options.context.errors, err => { - if (err) { - log.error(err); - options.context.errors.cifs = options.context.errors.cifs || err; - } - if (options.deleteOldBackup === true) { - if (cleanFiles(dir, options, options.context.types, options.deleteBackupAfter, log, options.context.errors)) { + if (dir == options.backupDir) { + callback && callback(`The storage path "${dir}" for copying is not configured correctly`); + } else { + copyFiles(dir, fileNames, log, options.context.errors, err => { + if (err) { + log.error(err); + options.context.errors.cifs = options.context.errors.cifs || err; + } + if (options.deleteOldBackup === true) { + if (cleanFiles(dir, options, options.context.types, options.deleteBackupAfter, log, options.context.errors)) { + !options.context.errors.cifs && options.context.done.push('cifs'); + } + } else { !options.context.errors.cifs && options.context.done.push('cifs'); } - } else { - !options.context.errors.cifs && options.context.done.push('cifs'); - } - if (callback) { - callback(err); - callback = null; - } - }); + if (callback) { + callback(err); + callback = null; + } + }); + } } else if (options.mountType === 'Copy') { - //callback(`Path "${options.dir}" not found`); callback && callback(`Path "${dir}" not found`); } else { callback && callback();