SyncingService

open class SyncingService(remoteStorage: RemoteStorage, localStorage: LocalStorage, attachmentsService: AttachmentService, getLocalUri: suspend (String) -> String, errorHandler: SyncErrorHandler?, logger: Logger, scope: CoroutineScope, syncThrottle: Duration = 5.seconds)

Service responsible for syncing attachments between local and remote storage.

This service handles downloading, uploading, and deleting attachments, as well as periodically syncing attachment states. It ensures proper lifecycle management of sync operations and provides mechanisms for error handling and retries.

The class provides a default implementation for syncing operations, which can be overridden by subclasses to customize behavior as needed.

Constructors

Link copied to clipboard
constructor(remoteStorage: RemoteStorage, localStorage: LocalStorage, attachmentsService: AttachmentService, getLocalUri: suspend (String) -> String, errorHandler: SyncErrorHandler?, logger: Logger, scope: CoroutineScope, syncThrottle: Duration = 5.seconds)

Functions

Link copied to clipboard
suspend fun close()

Closes the syncing service, stopping all operations and releasing resources.

Link copied to clipboard

Deletes archived attachments from local storage.

Link copied to clipboard
suspend fun startSync(period: Duration = 30.seconds)

Starts the syncing process, including periodic and event-driven sync operations.

Link copied to clipboard
suspend fun stopSync()

Stops all ongoing sync operations.

Link copied to clipboard
suspend fun triggerSync()

Enqueues a sync operation