fix(server): don't delete offline files from disk when trash empties ()

fix: don't delete offline files from disk when emptying trash

Move logic to asset deletion check
This commit is contained in:
Jonathan Jogenfors 2025-01-07 19:25:43 +01:00 committed by GitHub
parent 10e569cc1c
commit 23f3e737fd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 289 additions and 23 deletions
e2e/src

View file

@ -10,6 +10,7 @@ import {
Permission,
PersonCreateDto,
SharedLinkCreateDto,
UpdateLibraryDto,
UserAdminCreateDto,
UserPreferencesUpdateDto,
ValidateLibraryDto,
@ -35,6 +36,7 @@ import {
updateAlbumUser,
updateAssets,
updateConfig,
updateLibrary,
updateMyPreferences,
upsertTags,
validate,
@ -42,7 +44,7 @@ import {
import { BrowserContext } from '@playwright/test';
import { exec, spawn } from 'node:child_process';
import { createHash } from 'node:crypto';
import { existsSync, mkdirSync, rmSync, writeFileSync } from 'node:fs';
import { existsSync, mkdirSync, renameSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import path, { dirname } from 'node:path';
import { setTimeout as setAsyncTimeout } from 'node:timers/promises';
@ -392,6 +394,14 @@ export const utils = {
rmSync(path);
},
renameImageFile: (oldPath: string, newPath: string) => {
if (!existsSync(oldPath)) {
return;
}
renameSync(oldPath, newPath);
},
removeDirectory: (path: string) => {
if (!existsSync(path)) {
return;
@ -447,6 +457,9 @@ export const utils = {
validateLibrary: (accessToken: string, id: string, dto: ValidateLibraryDto) =>
validate({ id, validateLibraryDto: dto }, { headers: asBearerAuth(accessToken) }),
updateLibrary: (accessToken: string, id: string, dto: UpdateLibraryDto) =>
updateLibrary({ id, updateLibraryDto: dto }, { headers: asBearerAuth(accessToken) }),
createPartner: (accessToken: string, id: string) => createPartner({ id }, { headers: asBearerAuth(accessToken) }),
updateMyPreferences: (accessToken: string, userPreferencesUpdateDto: UserPreferencesUpdateDto) =>