Skip to content

Commit

Permalink
Fixes bug with opening previous version documents
Browse files Browse the repository at this point in the history
  • Loading branch information
Spoffy committed Sep 19, 2024
1 parent f016be6 commit a1b023b
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions ext/app/server/lib/DesktopDocStorageManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ export class DesktopDocStorageManager extends HostedStorageManager {

async loadFilePathsFromHomeDB(homeDb: HomeDBManager) {
for (const doc of await homeDb.getAllDocs()) {
// All Grist Desktop documents are supposed to have externalId set to their file path.
const docPath = doc.options?.externalId;
if (docPath && fileExists(docPath)) {
this.registerDocPath(doc.id, docPath);
}
// Most Grist Desktop documents will have externalId set to their file path.
// Some won't (e.g created in an older version), so try their default path.
const docPath = doc.options?.externalId || super.getPath(doc.id);
if (docPath && fileExists(docPath)) {
this.registerDocPath(doc.id, docPath);
}
}
};

Expand Down Expand Up @@ -78,6 +79,10 @@ export class DesktopDocStorageManager extends HostedStorageManager {
public lookupByPath(docPath: string): string | null {
return this._pathToIdMap.get(docPath) ?? null;
}

public getCachedPaths(): [string, string][] {
return Array.from(this._idToPathMap.entries());
}
}

export function isDesktopStorageManager(storageManager: IDocStorageManager): storageManager is DesktopDocStorageManager {
Expand Down

0 comments on commit a1b023b

Please sign in to comment.