One album or file quak cannot decrypt no longer stops a refresh or a backup (closes #181)
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
A file or album whose key, metadata or name does not decrypt used to throw out of the refresh, so quak backup stopped before storing anything, every run. Client.collectionsSince and filesSince now return such a row in undecryptable with the reason, the refresh leaves it out, and the store keeps the list in metadata.json until a later refresh decrypts or deletes the record. lib.backup() records each such file in failures.json unless a copy in another album decrypted, in which case it stores the original from that copy. Each such album is listed in BackupResult.undecryptableAlbums and printed as one FAILED album line. quak backup exits 1 while either remains. An album or file that no longer decrypts loses its album folder, JSON and links; its original stays. Model: opus-5-5
This commit was merged in pull request #188.
This commit is contained in:
+26
-1
@@ -601,6 +601,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),
|
||||
@@ -703,7 +704,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,
|
||||
@@ -740,9 +744,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;
|
||||
}
|
||||
|
||||
@@ -752,9 +764,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