Skip to content

Commit

Permalink
fix: handle case when no logs are available for today during export
Browse files Browse the repository at this point in the history
  • Loading branch information
biersoeckli committed Feb 2, 2025
1 parent 84e2fcc commit 5bc7209
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/app/project/app/[appId]/overview/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { getAuthUserSession, simpleAction } from "@/server/utils/action-wrapper.
import { PodsResourceInfoModel } from "@/shared/model/pods-resource-info.model";
import appLogsService from "@/server/services/standalone-services/app-logs.service";
import { DownloadableAppLogsModel } from "@/shared/model/downloadable-app-logs.model";
import { ServiceException } from "@/shared/model/service.exception.model";


export const getDeploymentsAndBuildsForApp = async (appId: string) =>
Expand Down Expand Up @@ -56,5 +57,9 @@ export const getDownloadableLogs = async (appId: string) =>
export const exportLogsToFileForToday = async (appId: string) =>
simpleAction(async () => {
await getAuthUserSession();
return new SuccessActionResult(await appLogsService.writeAppLogsToDiskForApp(appId));
const result = await appLogsService.writeAppLogsToDiskForApp(appId);
if (!result) {
throw new ServiceException('There are no logs available for today.');
}
return new SuccessActionResult();
}) as Promise<ServerActionResult<unknown, DownloadableAppLogsModel | undefined>>;
5 changes: 4 additions & 1 deletion src/server/services/standalone-services/app-logs.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ class AppLogsService {
const logFilePath = PathUtils.appLogsFile(app.id, startOfDay);
await FsUtils.deleteFileIfExists(logFilePath); // delete existing log file --> new one will be created

if (logPathsWritten.length === 0) {
return;
}

await create({
gzip: true,
Expand All @@ -142,7 +145,7 @@ class AppLogsService {
}

for (const logPath of logPathsWritten) {
//await FsUtils.deleteFileIfExists(logPath);
await FsUtils.deleteFileIfExists(logPath);
}

return {
Expand Down

0 comments on commit 5bc7209

Please sign in to comment.