diff --git a/app/server/lib/ExternalStorage.ts b/app/server/lib/ExternalStorage.ts index 7a399b9b..76080848 100644 --- a/app/server/lib/ExternalStorage.ts +++ b/app/server/lib/ExternalStorage.ts @@ -240,9 +240,12 @@ export class ChecksummedExternalStorage implements ExternalStorage { // exist in this case, and this should fail if it does. await fse.move(tmpPath, fname, {overwrite: false}); if (fromKey === toKey) { + // Save last S3 snapshot id observed for this key. await this._options.latestVersion.save(toKey, downloadedSnapshotId); + // Save last S3 hash observed for this key (so if we have a version with that hash + // locally we can skip pushing it back needlessly later). + await this._options.localHash.save(toKey, checksum); } - await this._options.localHash.save(toKey, checksum); log.info("ext %s download: %s%s%s with checksum %s and version %s", this.label, fromKey, snapshotId ? ` [VersionId ${snapshotId}]` : '', diff --git a/app/server/lib/HostedStorageManager.ts b/app/server/lib/HostedStorageManager.ts index 9ef8fe4d..1aa24313 100644 --- a/app/server/lib/HostedStorageManager.ts +++ b/app/server/lib/HostedStorageManager.ts @@ -252,6 +252,9 @@ export class HostedStorageManager implements IDocStorageManager { */ public async prepareFork(srcDocName: string, destDocName: string): Promise { await this.prepareLocalDoc(destDocName, srcDocName); + this.markAsChanged(destDocName); // Make sure fork is actually stored in S3, even + // if no changes are made, since we'd refuse to + // create it later. return this.getPath(destDocName); }