One album or file quak cannot decrypt no longer stops a refresh or a backup (closes #181)
collectionsSince and filesSince put a row that does not decrypt or parse in an undecryptable list with the reason instead of throwing. The refresh leaves it out, an album with its files, and the store keeps the list in metadata.json until the server sends a copy that decrypts or deletes it, since the next refresh asks only for changes. lib.backup() records each such file in failures.json as "could not be decrypted: <reason>", unless a copy in another album decrypted, logs one line per such album and lists their IDs in undecryptableAlbums; quak backup exits 1 while any remain. Tests use a stand-in Ente server with real encryption. Model: opus-5-5
This commit is contained in:
+26
-1
@@ -598,6 +598,7 @@ export class Library {
|
||||
refresh: () => this.refreshNow(),
|
||||
listCollections: () => this.store.listCollections(),
|
||||
listFiles: (id) => this.store.listFiles(id),
|
||||
undecryptable: () => this.store.listUndecryptable(),
|
||||
original: (fileID, destination) =>
|
||||
cache!.backupOriginal(fileID, destination),
|
||||
thumbnail: (fileID) => cache!.thumbnail(fileID),
|
||||
@@ -699,7 +700,10 @@ export class Library {
|
||||
|
||||
// Fetch every change since the stored cursor, then commit. All network
|
||||
// reads happen before any store mutation, so a fetch that throws leaves the
|
||||
// store untouched and the previous snapshot intact.
|
||||
// store untouched and the previous snapshot intact. A collection or file
|
||||
// that does not decrypt is left out instead, as if deleted, with the reason
|
||||
// kept in the store: the cursor moves past it, so no later refresh sees it
|
||||
// again until the server's copy changes.
|
||||
private async refreshOnce(): Promise<void> {
|
||||
const page = await this.client.collectionsSince({
|
||||
sinceTime: this.store.collectionsSinceTime,
|
||||
@@ -736,9 +740,17 @@ export class Library {
|
||||
this.store.deleteCollection(id);
|
||||
changed = true;
|
||||
}
|
||||
if (this.store.deleteUndecryptable(id)) changed = true;
|
||||
}
|
||||
// A collection left out takes its files with it.
|
||||
for (const { id, error } of page.undecryptable ?? []) {
|
||||
this.store.deleteCollection(id);
|
||||
this.store.putUndecryptable({ collectionID: id, error });
|
||||
changed = true;
|
||||
}
|
||||
for (const collection of page.collections) {
|
||||
this.store.putCollection(collection);
|
||||
this.store.deleteUndecryptable(collection.id);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
@@ -748,9 +760,22 @@ export class Library {
|
||||
this.store.deleteFile(collectionID, id);
|
||||
changed = true;
|
||||
}
|
||||
if (this.store.deleteUndecryptable(collectionID, id)) {
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
for (const { id, error } of filePage.undecryptable ?? []) {
|
||||
this.store.deleteFile(collectionID, id);
|
||||
this.store.putUndecryptable({
|
||||
collectionID,
|
||||
fileID: id,
|
||||
error,
|
||||
});
|
||||
changed = true;
|
||||
}
|
||||
for (const f of filePage.files) {
|
||||
this.store.putFile(f);
|
||||
this.store.deleteUndecryptable(collectionID, f.id);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user