diff --git a/common/spaces/fallback_space_primitives.ts b/common/spaces/fallback_space_primitives.ts index 9da72b4..1c98886 100644 --- a/common/spaces/fallback_space_primitives.ts +++ b/common/spaces/fallback_space_primitives.ts @@ -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", diff --git a/common/types.ts b/common/types.ts index 0d5a73b..cf54e60 100644 --- a/common/types.ts +++ b/common/types.ts @@ -6,4 +6,5 @@ export type FileMeta = { contentType: string; size: number; perm: "ro" | "rw"; + neverSync?: boolean; } & Record; diff --git a/web/client.ts b/web/client.ts index 7dd1a74..d1e3dc0 100644 --- a/web/client.ts +++ b/web/client.ts @@ -306,13 +306,11 @@ export class Client { (meta) => fileFilterFn(meta.name), // Run when a list of files has been retrieved async () => { - if (await this.syncService?.hasInitialSyncCompleted()) { - await this.loadSettings(); - if (typeof this.settings?.spaceIgnore === "string") { - fileFilterFn = gitIgnoreCompiler(this.settings.spaceIgnore).accepts; - } else { - fileFilterFn = () => true; - } + await this.loadSettings(); + if (typeof this.settings?.spaceIgnore === "string") { + fileFilterFn = gitIgnoreCompiler(this.settings.spaceIgnore).accepts; + } else { + fileFilterFn = () => true; } }, ); diff --git a/web/sync_service.ts b/web/sync_service.ts index 6a4aae1..e5e9a9c 100644 --- a/web/sync_service.ts +++ b/web/sync_service.ts @@ -177,14 +177,6 @@ export class SyncService { // Syncs a single file async syncFile(name: string) { - // Reminder: main reason to do this is not accidentally sync files retrieved via fallthrough (remote) and treat them as locally deleted - if (!await this.hasInitialSyncCompleted()) { - console.info( - "Initial sync hasn't happened yet, skipping sync for individual file", - name, - ); - return; - } if (await this.isSyncing()) { console.log("Already syncing, aborting individual file sync for", name); return; @@ -199,8 +191,16 @@ export class SyncService { let localHash: number | undefined; let remoteHash: number | undefined; try { - localHash = - (await this.localSpacePrimitives.getFileMeta(name)).lastModified; + const localMeta = await this.localSpacePrimitives.getFileMeta(name); + if (localMeta.neverSync) { + console.info( + "File marked as neverSync, skipping sync in this cycle", + name, + ); + await this.registerSyncStop(); + return; + } + localHash = localMeta.lastModified; } catch { // Not present }