Skip to content

Self-hosted personal gallery application with online photo management and albums, supporting Live/Motion Photos, EXIF parsing, geolocation recognition, and an explore map.

fix: exclude deleted photos from processing queue

Timothy Yinea70b68a54de
diff --git a/apps/cloud/app/components/CloudTransferPanel.vue b/apps/cloud/app/components/CloudTransferPanel.vue
index 8d4b4c13..ebe03688 100644
--- a/apps/cloud/app/components/CloudTransferPanel.vue
+++ b/apps/cloud/app/components/CloudTransferPanel.vue
@@ -34,6 +34,10 @@ watch(
initialSnapshot = false
}
const next = { ...tracked.value }
+ const present = new Set(items.map((job) => job.id))
+ for (const job of Object.values(next)) {
+ if (job.state !== 'succeeded' && !present.has(job.id)) delete next[job.id]
+ }
for (const job of items) {
if (active(job)) dismissed.delete(job.id)
if (
diff --git a/apps/cloud/server/api/sites/[siteId]/media/[...operation].ts b/apps/cloud/server/api/sites/[siteId]/media/[...operation].ts
index fe8279ec..05e15376 100644
--- a/apps/cloud/server/api/sites/[siteId]/media/[...operation].ts
+++ b/apps/cloud/server/api/sites/[siteId]/media/[...operation].ts
@@ -632,7 +632,7 @@ export default definePlatformHandler(async (event) => {
return {
photos: await ctx.resources.listPhotos(),
jobs: await sql(
- 'SELECT j.id,j.state,j.attempts,j.error_code,j.photo_id,u.file_name FROM cloud_processing_jobs j LEFT JOIN cloud_uploads u ON u.site_id=j.site_id AND u.id=j.upload_id WHERE j.site_id=? ORDER BY j.created_at DESC,j.id DESC LIMIT 100',
+ 'SELECT j.id,j.state,j.attempts,j.error_code,j.photo_id,u.file_name FROM cloud_processing_jobs j LEFT JOIN cloud_uploads u ON u.site_id=j.site_id AND u.id=j.upload_id WHERE j.site_id=? AND EXISTS(SELECT 1 FROM cloud_photos p WHERE p.site_id=j.site_id AND p.id=j.photo_id AND p.deleted=0) ORDER BY j.created_at DESC,j.id DESC LIMIT 100',
siteId,
),
}
diff --git a/tests/cloud-upload-albums.test.ts b/tests/cloud-upload-albums.test.ts
index 7f359ea1..56f5eaca 100644
--- a/tests/cloud-upload-albums.test.ts
+++ b/tests/cloud-upload-albums.test.ts
@@ -70,6 +70,7 @@ test('upload reservation persists canonical site-owned albums and refuses changi
target: ts.ScriptTarget.ES2022,
},
}).outputText
+ let operation = 'uploads'
const deps = {
definePlatformHandler: <T>(f: T) => f,
cloudMedia: async () => ({
@@ -79,12 +80,20 @@ test('upload reservation persists canonical site-owned albums and refuses changi
db,
raw: db,
repository,
+ resources: { listPhotos: async () => [] },
+ sql: async (query: string, ...values: (string | number | null)[]) =>
+ (
+ await db
+ .prepare(query)
+ .bind(...values)
+ .all()
+ ).results,
vault: {
list: async () => [{ id: 'storage', uploads_enabled: 1 }],
get: async () => ({ poolId: 'pool', enabled: true, revision: 1 }),
},
}),
- getRouterParam: () => 'uploads',
+ getRouterParam: () => operation,
siteManagementBody: async (event: RequestEvent) => event.body,
uploadAlbumIds,
validateUploadAlbums,
@@ -110,7 +119,7 @@ test('upload reservation persists canonical site-owned albums and refuses changi
code + '; return exports.default',
)({}, ...Object.values(deps)) as (
event: RequestEvent,
- ) => Promise<{ id: string }>
+ ) => Promise<{ id?: string; jobs?: { id: string; photo_id: string }[] }>
const body = {
requestId: 'upload',
connectionId: 'storage',
@@ -154,6 +163,36 @@ test('upload reservation persists canonical site-owned albums and refuses changi
.map((r) => r.album_id),
['1'],
)
+ operation = 'photos'
+ sqlite
+ .prepare(
+ "UPDATE cloud_processing_jobs SET state='failed' WHERE site_id=1 AND id='job'",
+ )
+ .run()
+ const beforeDelete = await api({ method: 'GET', body: {} })
+ assert.equal(beforeDelete.jobs?.length, 1) // Not-ready failures remain actionable.
+ sqlite
+ .prepare(
+ "INSERT INTO cloud_photos(site_id,id,source_version,title) VALUES(2,'upload','1','Other site')",
+ )
+ .run()
+ sqlite
+ .prepare(
+ "UPDATE cloud_photos SET deleted=1 WHERE site_id=1 AND id='upload'",
+ )
+ .run()
+ for (let visit = 0; visit < 2; visit++)
+ assert.deepEqual((await api({ method: 'GET', body: {} })).jobs, [])
+ assert.equal(
+ (
+ sqlite
+ .prepare(
+ "SELECT COUNT(*) AS total FROM cloud_processing_jobs WHERE site_id=1 AND id='job'",
+ )
+ .get() as { total: number }
+ ).total,
+ 1,
+ )
} finally {
sqlite.close()
}
diff --git a/tests/portal-review-regressions.test.ts b/tests/portal-review-regressions.test.ts
index 1cac05ab..5065a1ad 100644
--- a/tests/portal-review-regressions.test.ts
+++ b/tests/portal-review-regressions.test.ts
@@ -898,6 +898,9 @@ test('floating queue follows task completion and retry without showing historica
media.busy.value = false
state.removeFailed(failedJob)
assert.deepEqual(removed, ['never-ready'])
+ media.jobs.value = [] // The server omits tombstoned photos after deletion.
+ await nextTick()
+ assert.equal(state.processingJobs.value.length, 0)
// A new visit keeps historical failures accessible, but starts collapsed.
media.ready.value = false
media.jobs.value = [failedJob]