Skip to content

High performance self-hosted photo and video management solution.

fix(server): new full sync return stacked assets individually (#9189)

Fynn Petersen-Frey4d7aa7effd53
diff --git a/server/src/interfaces/asset.interface.ts b/server/src/interfaces/asset.interface.ts
index 79d90dde67..b523f36bfa 100644
--- a/server/src/interfaces/asset.interface.ts
+++ b/server/src/interfaces/asset.interface.ts
@@ -134,8 +134,6 @@ export interface AssetFullSyncOptions {
lastCreationDate?: Date;
lastId?: string;
updatedUntil: Date;
- isArchived?: false;
- withStacked?: true;
limit: number;
}
diff --git a/server/src/queries/asset.repository.sql b/server/src/queries/asset.repository.sql
index 27a74807f8..7cc133b039 100644
--- a/server/src/queries/asset.repository.sql
+++ b/server/src/queries/asset.repository.sql
@@ -1059,8 +1059,4 @@ FROM
WHERE
"asset"."isVisible" = true
AND "asset"."ownerId" IN ($1)
- AND (
- "stack"."primaryAssetId" = "asset"."id"
- OR "asset"."stackId" IS NULL
- )
AND "asset"."updatedAt" > $2
diff --git a/server/src/repositories/asset.repository.ts b/server/src/repositories/asset.repository.ts
index f9ed1c468c..59af894785 100644
--- a/server/src/repositories/asset.repository.ts
+++ b/server/src/repositories/asset.repository.ts
@@ -741,12 +741,11 @@ export class AssetRepository implements IAssetRepository {
],
})
getAllForUserFullSync(options: AssetFullSyncOptions): Promise<AssetEntity[]> {
- const { ownerId, isArchived, withStacked, lastCreationDate, lastId, updatedUntil, limit } = options;
+ const { ownerId, lastCreationDate, lastId, updatedUntil, limit } = options;
const builder = this.getBuilder({
userIds: [ownerId],
- exifInfo: true,
- withStacked,
- isArchived,
+ exifInfo: true, // also joins stack information
+ withStacked: false, // return all assets individually as expected by the app
});
if (lastCreationDate !== undefined && lastId !== undefined) {
@@ -767,9 +766,9 @@ export class AssetRepository implements IAssetRepository {
@GenerateSql({ params: [{ userIds: [DummyValue.UUID], updatedAfter: DummyValue.DATE }] })
getChangedDeltaSync(options: AssetDeltaSyncOptions): Promise<AssetEntity[]> {
- const builder = this.getBuilder({ userIds: options.userIds, exifInfo: true, withStacked: true })
+ const builder = this.getBuilder({ userIds: options.userIds, exifInfo: true, withStacked: false })
.andWhere({ updatedAt: MoreThan(options.updatedAfter) })
- .take(options.limit)
+ .limit(options.limit)
.withDeleted();
return builder.getMany();
diff --git a/server/src/services/sync.service.spec.ts b/server/src/services/sync.service.spec.ts
index 9a7dbbc152..a0ded6dba3 100644
--- a/server/src/services/sync.service.spec.ts
+++ b/server/src/services/sync.service.spec.ts
@@ -44,7 +44,6 @@ describe(SyncService.name, () => {
mapAsset(assetStub.hasEncodedVideo, mapAssetOpts),
]);
expect(assetMock.getAllForUserFullSync).toHaveBeenCalledWith({
- withStacked: true,
ownerId: authStub.user1.user.id,
updatedUntil: untilDate,
limit: 2,
diff --git a/server/src/services/sync.service.ts b/server/src/services/sync.service.ts
index 88a4e172a6..c0ac362d89 100644
--- a/server/src/services/sync.service.ts
+++ b/server/src/services/sync.service.ts
@@ -32,10 +32,6 @@ export class SyncService {
await this.access.requirePermission(auth, Permission.TIMELINE_READ, userId);
const assets = await this.assetRepository.getAllForUserFullSync({
ownerId: userId,
- // no archived assets for partner user
- isArchived: userId === auth.user.id ? undefined : false,
- // no stack for partner user
- withStacked: userId === auth.user.id ? true : undefined,
lastCreationDate: dto.lastCreationDate,
updatedUntil: dto.updatedUntil,
lastId: dto.lastId,