misc: optimized prune orphan snapshots

This commit is contained in:
Sheen Capadngan
2024-06-10 21:08:14 +08:00
parent d9c4c332ea
commit e696bff004
@@ -434,13 +434,12 @@ export const snapshotDALFactory = (db: TDbClient) => {
// cleanup orphaned snapshots (those that don't belong to an existing folder and folder version) // cleanup orphaned snapshots (those that don't belong to an existing folder and folder version)
await db(TableName.Snapshot) await db(TableName.Snapshot)
// eslint-disable-next-line func-names
.whereNotIn("folderId", function () { .whereNotIn("folderId", function () {
void this.select("folderId").from(TableName.SecretFolderVersion); void this.select("folderId")
}) .from(TableName.SecretFolderVersion)
// eslint-disable-next-line func-names .union(function () {
.whereNotIn("folderId", function () { void this.select("id").from(TableName.SecretFolder);
void this.select("folderId").from(TableName.SecretFolder); });
}) })
.delete(); .delete();
} catch (error) { } catch (error) {