mirror of
https://github.com/Sebclem/hassio-nextcloud-backup.git
synced 2024-11-22 17:22:58 +01:00
🔨 Clean at the end of upload
This commit is contained in:
parent
cdcbac4bc6
commit
4dec2579f5
@ -8,6 +8,7 @@ const configPath = "./webdav_conf.json"
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const settingsTools = require('./settingsTools');
|
const settingsTools = require('./settingsTools');
|
||||||
const pathTools = require('./pathTools');
|
const pathTools = require('./pathTools');
|
||||||
|
const hassioApiTools = require('./hassioApiTools');
|
||||||
|
|
||||||
const request = require('request');
|
const request = require('request');
|
||||||
|
|
||||||
@ -202,7 +203,17 @@ class WebdavTools {
|
|||||||
|
|
||||||
statusTools.setStatus(status);
|
statusTools.setStatus(status);
|
||||||
cleanTempFolder();
|
cleanTempFolder();
|
||||||
|
let autoCleanCloud = settingsTools.getSettings().auto_clean_backup;
|
||||||
|
if (autoCleanCloud != null && autoCleanCloud == "true") {
|
||||||
|
this.clean().catch();
|
||||||
|
}
|
||||||
|
let autoCleanlocal = settingsTools.getSettings().auto_clean_local;
|
||||||
|
if (autoCleanlocal != null && autoCleanlocal == "true") {
|
||||||
|
hassioApiTools.clean();
|
||||||
|
}
|
||||||
resolve();
|
resolve();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
@ -221,7 +232,7 @@ class WebdavTools {
|
|||||||
|
|
||||||
clean() {
|
clean() {
|
||||||
let limit = settingsTools.getSettings().auto_clean_local_keep;
|
let limit = settingsTools.getSettings().auto_clean_local_keep;
|
||||||
if(limit == null)
|
if (limit == null)
|
||||||
limit = 5;
|
limit = 5;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.getFolderContent(pathTools.auto).then(async (contents) => {
|
this.getFolderContent(pathTools.auto).then(async (contents) => {
|
||||||
@ -246,7 +257,7 @@ class WebdavTools {
|
|||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
status.status = "error";
|
status.status = "error";
|
||||||
status.error_code = 6;
|
status.error_code = 6;
|
||||||
status.message = "Fail to clean Nexcloud ("+ error + ") !"
|
status.message = "Fail to clean Nexcloud (" + error + ") !"
|
||||||
statusTools.setStatus(status);
|
statusTools.setStatus(status);
|
||||||
console.error(status.message);
|
console.error(status.message);
|
||||||
reject(status.message);
|
reject(status.message);
|
||||||
|
Loading…
Reference in New Issue
Block a user