Class

RemoteFileSync

RemoteFileSync()

Provider-agnostic base class for two-way synchronization of a single file with a remote storage.

Subclasses implement the primitives (getRemoteFileInfo, downloadFile, uploadFile, isFileSynced, getLocalFileHash, testAuthentication, listFolderEntries). The sync decision logic lives in syncFileTwoWay().

syncFileTwoWay() return codes: 0 already in sync 1 downloaded remote file 2 uploaded local file -1 download failed -2 upload failed -3 not in sync after operation (reserved; mapped to 'SYNC FAILED' by ipc_db_handler) -4 uploaded, but not in sync afterwards (remote file may be corrupted) -5 local file missing -6 could not determine sync status

Constructor

# new RemoteFileSync()

View Source backend/cloud_sync/remote_file_sync.js, line 44

Methods

# async _withRetry(apiCall, operationName, trackRetries)

Execute an API call with retry logic and exponential backoff.

Parameters:
Name Type Default Description
apiCall function

Async function that performs the API call

operationName string API call

Name of the operation for logging

trackRetries boolean false

Whether to return {result, retryCount} instead of the plain result

View Source backend/cloud_sync/remote_file_sync.js, line 122

# async listFolderEntries(remotePath) → {Promise.<Array.<{name: string, path: string, isFolder: boolean, size: number}>>}

List the direct children of a remote folder.

Parameters:
Name Type Description
remotePath string

folder path ('' or '/' for the root), in the same form as accepted by downloadFile()

View Source backend/cloud_sync/remote_file_sync.js, line 76

an error with notFound = true if the folder does not exist

path of each entry can be passed to listFolderEntries() / downloadFile() again.

Promise.<Array.<{name: string, path: string, isFolder: boolean, size: number}>>

# async refreshAccessToken()

Refresh the access credentials if the provider uses expiring tokens. No-op by default.

View Source backend/cloud_sync/remote_file_sync.js, line 81