mirror of
https://github.com/Sebclem/hassio-nextcloud-backup.git
synced 2024-11-25 02:22:58 +01:00
Check webdav folder more often
This commit is contained in:
parent
f54bcdfc58
commit
43367602d9
@ -12,6 +12,7 @@ import { WebdavDeleteValidation } from "../types/services/webdavValidation.js";
|
||||
import { restoreToHA } from "../services/orchestrator.js";
|
||||
import path from "path";
|
||||
import logger from "../config/winston.js";
|
||||
import { getStatus } from "../tools/status.js";
|
||||
|
||||
const webdavRouter = express.Router();
|
||||
|
||||
@ -22,6 +23,13 @@ webdavRouter.get("/backup/auto", (req, res) => {
|
||||
.then(() => {
|
||||
return webdavService.checkWebdavLogin(config);
|
||||
})
|
||||
.then(() => {
|
||||
if (!getStatus().webdav.folder_created) {
|
||||
return webdavService.createBackupFolder(config);
|
||||
} else {
|
||||
return Promise.resolve();
|
||||
}
|
||||
})
|
||||
.then(async () => {
|
||||
const value = await webdavService.getBackups(
|
||||
pathTools.auto,
|
||||
@ -43,6 +51,13 @@ webdavRouter.get("/backup/manual", (req, res) => {
|
||||
.then(() => {
|
||||
return webdavService.checkWebdavLogin(config);
|
||||
})
|
||||
.then(() => {
|
||||
if (!getStatus().webdav.folder_created) {
|
||||
return webdavService.createBackupFolder(config);
|
||||
} else {
|
||||
return Promise.resolve();
|
||||
}
|
||||
})
|
||||
.then(async () => {
|
||||
const value = await webdavService.getBackups(
|
||||
pathTools.manual,
|
||||
@ -68,6 +83,13 @@ webdavRouter.delete("/", (req, res) => {
|
||||
.then(() => {
|
||||
return webdavService.checkWebdavLogin(config);
|
||||
})
|
||||
.then(() => {
|
||||
if (!getStatus().webdav.folder_created) {
|
||||
return webdavService.createBackupFolder(config);
|
||||
} else {
|
||||
return Promise.resolve();
|
||||
}
|
||||
})
|
||||
.then(() => {
|
||||
webdavService
|
||||
.deleteBackup(body.path, config)
|
||||
|
@ -42,6 +42,13 @@ export function doBackupWorkflow(type: WorkflowType) {
|
||||
);
|
||||
return webDavService.checkWebdavLogin(webdavConfig);
|
||||
})
|
||||
.then(() => {
|
||||
if (!statusTools.getStatus().webdav.folder_created) {
|
||||
return webDavService.createBackupFolder(webdavConfig);
|
||||
} else {
|
||||
return Promise.resolve();
|
||||
}
|
||||
})
|
||||
.then(() => {
|
||||
return homeAssistantService.stopAddons(addonsToStartStop);
|
||||
})
|
||||
@ -128,6 +135,13 @@ export function uploadToCloud(slug: string) {
|
||||
|
||||
return webDavService
|
||||
.checkWebdavLogin(webdavConfig)
|
||||
.then(() => {
|
||||
if (!statusTools.getStatus().webdav.folder_created) {
|
||||
return webDavService.createBackupFolder(webdavConfig);
|
||||
} else {
|
||||
return Promise.resolve();
|
||||
}
|
||||
})
|
||||
.then(() => {
|
||||
return homeAssistantService.getBackupInfo(slug);
|
||||
})
|
||||
@ -210,6 +224,13 @@ export function restoreToHA(webdavPath: string, filename: string) {
|
||||
const webdavConfig = getWebdavConfig();
|
||||
return webDavService
|
||||
.checkWebdavLogin(webdavConfig)
|
||||
.then(() => {
|
||||
if (!statusTools.getStatus().webdav.folder_created) {
|
||||
return webDavService.createBackupFolder(webdavConfig);
|
||||
} else {
|
||||
return Promise.resolve();
|
||||
}
|
||||
})
|
||||
.then(() => {
|
||||
return webDavService.downloadFile(webdavPath, filename, webdavConfig);
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user