Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
etnoy committed Feb 8, 2025
1 parent 9217757 commit 5819e1e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
3 changes: 3 additions & 0 deletions server/src/queries/asset.repository.sql
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,9 @@ with
where
"assets"."deletedAt" is null
and "assets"."isVisible" = $2
and "assets"."fileCreatedAt" is not null
and "assets"."fileModifiedAt" is not null
and "assets"."localDateTime" is not null
)
select
"timeBucket",
Expand Down
5 changes: 4 additions & 1 deletion server/src/queries/library.repository.sql
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ from
inner join "assets" on "assets"."libraryId" = "libraries"."id"
left join "exif" on "exif"."assetId" = "assets"."id"
where
"libraries"."id" = $6
"assets"."fileCreatedAt" is not null
and "assets"."fileModifiedAt" is not null
and "assets"."localDateTime" is not null
and "libraries"."id" = $6
group by
"libraries"."id"
select
Expand Down
3 changes: 0 additions & 3 deletions server/src/repositories/asset.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,6 @@ export class AssetRepository implements IAssetRepository {
)
.innerJoin('exif', 'a.id', 'exif.assetId')
.selectAll('a')
.$narrowType<{ fileCreatedAt: NotNull }>()
.$narrowType<{ fileModifiedAt: NotNull }>()
.$narrowType<{ localDateTime: NotNull }>()
.select((eb) => eb.fn.toJson(eb.table('exif')).as('exifInfo')),
)
.selectFrom('res')
Expand Down
3 changes: 3 additions & 0 deletions server/src/repositories/library.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ export class LibraryRepository implements ILibraryRepository {
const stats = await this.db
.selectFrom('libraries')
.innerJoin('assets', 'assets.libraryId', 'libraries.id')
.where('assets.fileCreatedAt', 'is not', null)
.where('assets.fileModifiedAt', 'is not', null)
.where('assets.localDateTime', 'is not', null)
.leftJoin('exif', 'exif.assetId', 'assets.id')
.select((eb) =>
eb.fn
Expand Down
9 changes: 7 additions & 2 deletions server/src/services/library.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -574,9 +574,14 @@ export class LibraryService extends BaseService {
}

const mtime = stat.mtime;
const isTimeUpdated = !asset.fileModifiedAt || mtime.toISOString() !== asset.fileModifiedAt.toISOString();

if (isTimeUpdated) {
if (!asset.fileModifiedAt || !asset.fileCreatedAt || !asset.localDateTime) {
this.logger.verbose(`Asset ${asset.originalPath} needs metadata extraction in library ${libraryId}`);

return AssetSyncResult.UPDATE;
}

if (mtime.toISOString() !== asset.fileModifiedAt.toISOString()) {
this.logger.verbose(
`Asset ${asset.originalPath} modification time changed from ${asset.fileModifiedAt?.toISOString()} to ${mtime.toISOString()}, queuing re-import in library ${libraryId}`,
);
Expand Down

0 comments on commit 5819e1e

Please sign in to comment.