diff --git a/server/src/repositories/asset.repository.ts b/server/src/repositories/asset.repository.ts index b7c0d13aa73f4..9f21a79a31d3b 100644 --- a/server/src/repositories/asset.repository.ts +++ b/server/src/repositories/asset.repository.ts @@ -50,6 +50,8 @@ import { anyUuid, asUuid, mapUpsertColumns } from 'src/utils/database'; import { globToSqlPattern } from 'src/utils/misc'; import { Paginated, PaginationOptions, paginationHelper } from 'src/utils/pagination'; +const ASSET_CUTOFF_DATE = new Date('9000-01-01'); + @Injectable() export class AssetRepository implements IAssetRepository { constructor(@InjectKysely() private db: Kysely) {} @@ -527,6 +529,7 @@ export class AssetRepository implements IAssetRepository { return this.db .selectFrom('assets') .selectAll('assets') + .where('assets.fileCreatedAt', '<=', ASSET_CUTOFF_DATE) .$call(withExif) .where('ownerId', '=', anyUuid(userIds)) .where('isVisible', '=', true) @@ -543,6 +546,7 @@ export class AssetRepository implements IAssetRepository { .with('assets', (qb) => qb .selectFrom('assets') + .where('assets.fileCreatedAt', '<=', ASSET_CUTOFF_DATE) .select(truncatedDate(options.size).as('timeBucket')) .$if(!!options.isTrashed, (qb) => qb.where('assets.status', '!=', AssetStatus.DELETED)) .where('assets.deletedAt', options.isTrashed ? 'is not' : 'is', null) @@ -592,6 +596,7 @@ export class AssetRepository implements IAssetRepository { async getTimeBucket(timeBucket: string, options: TimeBucketOptions): Promise { return hasPeople(this.db, options.personId ? [options.personId] : undefined) .selectAll('assets') + .where('assets.fileCreatedAt', '<=', ASSET_CUTOFF_DATE) .$call(withExif) .$if(!!options.albumId, (qb) => withAlbums(qb, { albumId: options.albumId })) .$if(!!options.userIds, (qb) => qb.where('assets.ownerId', '=', anyUuid(options.userIds!))) diff --git a/server/src/services/library.service.ts b/server/src/services/library.service.ts index 1eac80913468f..2e8bbe3b965f5 100644 --- a/server/src/services/library.service.ts +++ b/server/src/services/library.service.ts @@ -24,6 +24,8 @@ import { mimeTypes } from 'src/utils/mime-types'; import { handlePromiseError } from 'src/utils/misc'; import { usePagination } from 'src/utils/pagination'; +const ASSET_IMPORT_DATE = new Date('9999-12-31'); + @Injectable() export class LibraryService extends BaseService { private watchLibraries = false; @@ -378,9 +380,9 @@ export class LibraryService extends BaseService { checksum: this.cryptoRepository.hashSha1(`path:${assetPath}`), originalPath: assetPath, - fileCreatedAt: new Date(), - fileModifiedAt: new Date(), - localDateTime: new Date(), + fileCreatedAt: ASSET_IMPORT_DATE, + fileModifiedAt: ASSET_IMPORT_DATE, + localDateTime: ASSET_IMPORT_DATE, // TODO: device asset id is deprecated, remove it deviceAssetId: `${basename(assetPath)}`.replaceAll(/\s+/g, ''), deviceId: 'Library Import', diff --git a/server/src/services/metadata.service.ts b/server/src/services/metadata.service.ts index f1d6389e02f52..4b092d27614e4 100644 --- a/server/src/services/metadata.service.ts +++ b/server/src/services/metadata.service.ts @@ -175,10 +175,10 @@ export class MetadataService extends BaseService { let fileCreatedAtDate = dateTimeOriginal; let fileModifiedAtDate = modifyDate; - /* if (asset.isExternal) { + if (asset.isExternal) { fileCreatedAtDate = fileCreatedAt; fileModifiedAtDate = fileModifiedAt; - } */ + } const exifData: Insertable = { assetId: asset.id,