Files
plainleaf/plugs/sync/sync.ts
T
Zef HemelandGitHub dc2987a3f9 Sync engine rearchitecture (#1516)
* Don't require auth for .ping
* Finally introducing loggers
* Remove file list caching from disk_space_primitives
I don't think this is required anymore with the sync model
* Simplification of space primitives and more tests
* More reliable online status
* Add .zed settings
* Remove selfUpdate argument from `writeFile` no longer used
- Add `sync` config schema and document sync options
- Move sync config handling to client boot logic
- Move BootConfig type to ui_types.ts
- Remove sync env vars from server
- Update documentation for sync and architecture
* Improve sync logic and proxy routing for full sync state
* Add BoxProxy for late-bound client and improve Lua boot
- Add isMobile syscall for editor
* Add concurrency to sync process and log indexing duration
* Better service worker lifecycle management
2025-09-12 14:43:57 +02:00

50 lines
1.1 KiB
TypeScript

import {
editor,
index,
space,
sync,
} from "@silverbulletmd/silverbullet/syscalls";
export async function syncSpaceCommand() {
await editor.flashNotification("Syncing space...");
await sync.performSpaceSync();
await editor.flashNotification("Done.");
}
export async function syncFileCommand() {
await editor.flashNotification("Syncing file...");
await sync.performFileSync(await editor.getCurrentPath());
await editor.flashNotification("Done.");
}
export async function spaceSyncComplete(message: { operations: number }) {
if (message.operations > 0) {
// Update the page list
await space.listFiles();
}
index.ensureFullIndex();
}
export async function updateSyncStatus(
event: {
status: {
filesProcessed: number;
totalFiles: number;
};
},
) {
// Update the status in the UI
await editor.showProgress(
Math.round((event.status.filesProcessed / event.status.totalFiles) * 100),
"sync",
);
}
export async function reportSyncConflict({ path }: { path: string }) {
await editor.flashNotification(
`Sync: conflict detected for ${path} - conflict copy created`,
"error",
);
}