MCPcopy
hub / github.com/codedogQBY/ReadAny / ISyncBackend

Interface ISyncBackend

packages/core/src/sync/sync-backend.ts:19–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17
18/** Unified sync backend interface */
19export interface ISyncBackend {
20 /** Backend type identifier */
21 readonly type: SyncBackendType;
22
23 /** Test if the backend is reachable and credentials are valid */
24 testConnection(): Promise<boolean>;
25
26 /** Ensure the remote directory structure exists */
27 ensureDirectories(): Promise<void>;
28
29 /** Upload data to a path */
30 put(path: string, data: Uint8Array): Promise<void>;
31
32 /** Download data from a path */
33 get(path: string): Promise<Uint8Array>;
34
35 /** Download data with progress reporting (optional — falls back to get() if not implemented) */
36 getWithProgress?(
37 path: string,
38 onProgress?: (loaded: number, total: number) => void,
39 ): Promise<Uint8Array>;
40
41 /** Upload a local file directly when the platform/backend supports native file transfer. */
42 putFile?(
43 path: string,
44 localFilePath: string,
45 onProgress?: (loaded: number, total: number) => void,
46 ): Promise<void>;
47
48 /** Download directly into a local file when the platform/backend supports native file transfer. */
49 getFileToPath?(
50 path: string,
51 localFilePath: string,
52 onProgress?: (loaded: number, total: number) => void,
53 ): Promise<void>;
54
55 /** Get JSON data from a path, returns null if not found */
56 getJSON<T>(path: string): Promise<T | null>;
57
58 /** Upload JSON data to a path */
59 putJSON<T>(path: string, data: T): Promise<void>;
60
61 /** List directory contents */
62 listDir(path: string): Promise<RemoteFile[]>;
63
64 /** Delete a file at the given path */
65 delete(path: string): Promise<void>;
66
67 /** Check if a file exists */
68 exists(path: string): Promise<boolean>;
69
70 /**
71 * Move/rename a file from `fromPath` to `toPath`.
72 * Implementations should create intermediate directories on the destination side.
73 * Should be atomic where the backend supports it; otherwise copy + delete.
74 * Throws if the source does not exist or if the destination already exists.
75 */
76 move(fromPath: string, toPath: string): Promise<void>;

Callers 52

LanSectionFunction · 0.65
sync-store.tsFile · 0.65
testConnectionMethod · 0.65
LANSyncDialogFunction · 0.65
runSimpleSyncFunction · 0.65
uploadFileToRemoteFunction · 0.65
putMethod · 0.65
onMethod · 0.65
offMethod · 0.65
emitMethod · 0.65
convertToMessageV2Function · 0.65

Implementers 5

WebDavBackendpackages/core/src/sync/webdav-backend.
S3Backendpackages/core/src/sync/s3-backend.ts
LocalFsBackendpackages/core/src/sync/lan-server.ts
LANBackendpackages/core/src/sync/lan-backend.ts
MemoryBackendpackages/core/src/sync/__tests__/simpl

Calls

no outgoing calls

Tested by

no test coverage detected