mirror of
https://github.com/biersoeckli/QuickStack.git
synced 2026-02-10 21:49:19 -06:00
fix: ensure log files are zipped before deletion
This commit is contained in:
@@ -10,6 +10,7 @@ import path from "path";
|
||||
import { create } from 'tar'
|
||||
import scheduleService from "./schedule.service";
|
||||
import { DownloadableAppLogsModel } from "../../../shared/model/downloadable-app-logs.model";
|
||||
import { CommandExecutorUtils } from "../../../server/utils/command-executor.utils";
|
||||
|
||||
class AppLogsService {
|
||||
|
||||
@@ -124,11 +125,20 @@ class AppLogsService {
|
||||
// create tar.gz file from all log files
|
||||
const logFilePath = PathUtils.appLogsFile(app.id, startOfDay);
|
||||
await FsUtils.deleteFileIfExists(logFilePath); // delete existing log file --> new one will be created
|
||||
|
||||
/*
|
||||
// this doesn't work, because it doesn't wait for the file to be written
|
||||
await create({
|
||||
gzip: true,
|
||||
file: logFilePath,
|
||||
cwd: PathUtils.appLogsFolder(app.id)
|
||||
}, logPathsWritten);
|
||||
*/
|
||||
|
||||
await CommandExecutorUtils.runCommand(`tar -czf ${logFilePath} ${logPathsWritten.join(' ')}`);
|
||||
if (!FsUtils.fileExists(logFilePath)) {
|
||||
throw new Error(`Error creating tar file for logs of app ${app.id} on path ${logFilePath}`);
|
||||
}
|
||||
|
||||
for (const logPath of logPathsWritten) {
|
||||
await FsUtils.deleteFileIfExists(logPath);
|
||||
|
||||
Reference in New Issue
Block a user