From c2d68232a5c4c0ba587e922324a205d55b90e510 Mon Sep 17 00:00:00 2001 From: Sebastien Clement Date: Fri, 10 Jan 2020 21:29:49 +0100 Subject: [PATCH] :hammer: Change config location --- nextcloud_backup/rootfs/opt/nextcloud_backup/app.js | 6 +++++- nextcloud_backup/rootfs/opt/nextcloud_backup/routes/api.js | 5 ++++- .../rootfs/opt/nextcloud_backup/tools/settingsTools.js | 2 +- .../rootfs/opt/nextcloud_backup/tools/status.js | 2 +- .../rootfs/opt/nextcloud_backup/tools/webdavTools.js | 6 +++++- 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/nextcloud_backup/rootfs/opt/nextcloud_backup/app.js b/nextcloud_backup/rootfs/opt/nextcloud_backup/app.js index 10380b0..f98617d 100644 --- a/nextcloud_backup/rootfs/opt/nextcloud_backup/app.js +++ b/nextcloud_backup/rootfs/opt/nextcloud_backup/app.js @@ -38,7 +38,9 @@ app.use(function(err, req, res, next) { res.render('error'); }); - +const fs = require('fs'); +if (!fs.existsSync('/data')) + fs.mkdirSync('/data'); const statusTools = require('./tools/status'); statusTools.init(); console.log("Satus : \x1b[32mGo !\x1b[0m") @@ -68,4 +70,6 @@ const cronTools = require('./tools/cronTools'); cronTools.startCron(); + + module.exports = app; diff --git a/nextcloud_backup/rootfs/opt/nextcloud_backup/routes/api.js b/nextcloud_backup/rootfs/opt/nextcloud_backup/routes/api.js index 62031fd..ee08b34 100644 --- a/nextcloud_backup/rootfs/opt/nextcloud_backup/routes/api.js +++ b/nextcloud_backup/rootfs/opt/nextcloud_backup/routes/api.js @@ -53,6 +53,8 @@ router.get('/formated-backup-manual', function(req, res, next) { return -1; }) res.render('backupSnaps',{backups: contents, moment: moment}); + }).catch(()=>{ + res.send(); }); }); @@ -67,8 +69,9 @@ router.get('/formated-backup-auto', function(req, res, next) { return -1; }) res.render('backupSnaps',{backups: contents, moment: moment}); + }).catch(()=>{ + res.send(); }); - }); diff --git a/nextcloud_backup/rootfs/opt/nextcloud_backup/tools/settingsTools.js b/nextcloud_backup/rootfs/opt/nextcloud_backup/tools/settingsTools.js index 0ee8030..7686513 100644 --- a/nextcloud_backup/rootfs/opt/nextcloud_backup/tools/settingsTools.js +++ b/nextcloud_backup/rootfs/opt/nextcloud_backup/tools/settingsTools.js @@ -1,6 +1,6 @@ const fs = require('fs'); -const settingsPath = "./backup_conf.json" +const settingsPath = "/data/backup_conf.json" function getSettings(){ diff --git a/nextcloud_backup/rootfs/opt/nextcloud_backup/tools/status.js b/nextcloud_backup/rootfs/opt/nextcloud_backup/tools/status.js index 4d7c50b..efe6a5e 100644 --- a/nextcloud_backup/rootfs/opt/nextcloud_backup/tools/status.js +++ b/nextcloud_backup/rootfs/opt/nextcloud_backup/tools/status.js @@ -1,6 +1,6 @@ const fs = require('fs'); -const statusPath = './status.json' +const statusPath = '/data/status.json' let baseStatus = { status: "idle", diff --git a/nextcloud_backup/rootfs/opt/nextcloud_backup/tools/webdavTools.js b/nextcloud_backup/rootfs/opt/nextcloud_backup/tools/webdavTools.js index 23dedd2..b74d397 100644 --- a/nextcloud_backup/rootfs/opt/nextcloud_backup/tools/webdavTools.js +++ b/nextcloud_backup/rootfs/opt/nextcloud_backup/tools/webdavTools.js @@ -4,7 +4,7 @@ const moment = require('moment'); const statusTools = require('./status'); const endpoint = "/remote.php/webdav" -const configPath = "./webdav_conf.json" +const configPath = "/data/webdav_conf.json" const path = require('path'); const settingsTools = require('./settingsTools'); const pathTools = require('./pathTools'); @@ -221,6 +221,10 @@ class WebdavTools { getFolderContent(path) { return new Promise((resolve, reject) => { + if(this.client == null){ + reject(); + return; + } this.client.getDirectoryContents(path) .then((contents) => { resolve(contents);