Skip to content

High performance self-hosted photo and video management solution.

fix: missing files integrity checks (#29737)

Daniel Dietzler66e30d5fa161
diff --git a/server/src/queries/integrity.repository.sql b/server/src/queries/integrity.repository.sql
index 937d4454a2..8d8461e700 100644
--- a/server/src/queries/integrity.repository.sql
+++ b/server/src/queries/integrity.repository.sql
@@ -86,7 +86,7 @@ select
from
"asset_file"
--- IntegrityRepository.streamAssetPaths
+-- IntegrityRepository.streamAssetPathsForMissingFiles
select
"allPaths"."path" as "path",
"allPaths"."assetId",
diff --git a/server/src/repositories/integrity.repository.ts b/server/src/repositories/integrity.repository.ts
index 19435650df..3eb9fb58d7 100644
--- a/server/src/repositories/integrity.repository.ts
+++ b/server/src/repositories/integrity.repository.ts
@@ -119,7 +119,7 @@ export class IntegrityRepository {
}
@GenerateSql({ params: [], stream: true })
- streamAssetPaths() {
+ streamAssetPathsForMissingFiles() {
return this.db
.selectFrom((eb) =>
eb
@@ -143,7 +143,7 @@ export class IntegrityRepository {
)
.leftJoin('integrity_report', (join) =>
join
- .on('integrity_report.type', '=', IntegrityReport.UntrackedFile)
+ .on('integrity_report.type', '=', IntegrityReport.MissingFile)
.on((eb) =>
eb.or([
eb('integrity_report.assetId', '=', eb.ref('allPaths.assetId')),
diff --git a/server/src/services/integrity.service.ts b/server/src/services/integrity.service.ts
index b3aa3fcd3f..2a9d869be3 100644
--- a/server/src/services/integrity.service.ts
+++ b/server/src/services/integrity.service.ts
@@ -360,7 +360,7 @@ export class IntegrityService extends BaseService {
this.logger.log(`Scanning for missing files...`);
- const assetPaths = this.integrityRepository.streamAssetPaths();
+ const assetPaths = this.integrityRepository.streamAssetPathsForMissingFiles();
let total = 0;
for await (const batchPaths of chunk(assetPaths, JOBS_LIBRARY_PAGINATION_SIZE)) {
diff --git a/server/test/medium/specs/services/integrity.service.spec.ts b/server/test/medium/specs/services/integrity.service.spec.ts
index f5de014867..919b009479 100644
--- a/server/test/medium/specs/services/integrity.service.spec.ts
+++ b/server/test/medium/specs/services/integrity.service.spec.ts
@@ -408,7 +408,7 @@ describe(IntegrityService.name, () => {
} = await ctx.newAsset({ ownerId, originalPath: '/path/to/file2' });
const { id: reportId } = await ctx.get(IntegrityRepository).create({
- type: IntegrityReport.UntrackedFile,
+ type: IntegrityReport.MissingFile,
path: '/path/to/file2',
assetId: assetId2,
});