More robust way to resolve initial sync bug

This commit is contained in:
Zef Hemel
2023-07-28 21:22:06 +02:00
parent fb67cba6ac
commit 8a790aae9e
4 changed files with 23 additions and 19 deletions
+7 -2
View File
@@ -27,7 +27,11 @@ export class FallbackSpacePrimitives implements SpacePrimitives {
e.message,
);
try {
return await this.fallback.readFile(name);
const result = await this.fallback.readFile(name);
return {
data: result.data,
meta: { ...result.meta, neverSync: true },
};
} catch (fallbackError: any) {
console.error("Error during readFile fallback", fallbackError.message);
// Fallback failed, so let's throw the original error
@@ -44,7 +48,8 @@ export class FallbackSpacePrimitives implements SpacePrimitives {
e.message,
);
try {
return await this.fallback.getFileMeta(name);
const meta = await this.fallback.getFileMeta(name);
return { ...meta, neverSync: true };
} catch (fallbackError) {
console.error(
"Error during getFileMeta fallback",
+1
View File
@@ -6,4 +6,5 @@ export type FileMeta = {
contentType: string;
size: number;
perm: "ro" | "rw";
neverSync?: boolean;
} & Record<string, any>;