@@ -6,7 +6,7 @@ import Foundation
66/// This watches for changes to active attachments and performs queued
77/// download, upload, and delete operations. Syncs can be triggered manually,
88/// periodically, or based on database changes.
9- public protocol SyncingService : Sendable {
9+ public protocol SyncingServiceProtocol : Sendable {
1010 /// Starts periodic syncing of attachments.
1111 ///
1212 /// - Parameter period: The time interval in seconds between each sync.
@@ -26,10 +26,10 @@ public protocol SyncingService: Sendable {
2626 func deleteArchivedAttachments( _ context: AttachmentContext ) async throws -> Bool
2727}
2828
29- actor SyncingServiceImpl : SyncingService {
29+ public actor SyncingService : SyncingServiceProtocol {
3030 private let remoteStorage : RemoteStorageAdapter
3131 private let localStorage : LocalStorageAdapter
32- private let attachmentsService : AttachmentService
32+ private let attachmentsService : AttachmentServiceProtocol
3333 private let getLocalUri : @Sendable ( String) async -> String
3434 private let errorHandler : SyncErrorHandler ?
3535 private let syncThrottle : TimeInterval
@@ -54,7 +54,7 @@ actor SyncingServiceImpl: SyncingService {
5454 public init (
5555 remoteStorage: RemoteStorageAdapter ,
5656 localStorage: LocalStorageAdapter ,
57- attachmentsService: AttachmentService ,
57+ attachmentsService: AttachmentServiceProtocol ,
5858 logger: any LoggerProtocol ,
5959 getLocalUri: @Sendable @escaping ( String) async -> String ,
6060 errorHandler: SyncErrorHandler ? = nil ,
@@ -106,23 +106,23 @@ actor SyncingServiceImpl: SyncingService {
106106 }
107107
108108 /// Cleans up internal resources and cancels any ongoing syncing.
109- func close( ) async throws {
109+ public func close( ) async throws {
110110 try guardClosed ( )
111111
112112 try await _stopSync ( )
113113 closed = true
114114 }
115115
116116 /// Triggers a sync operation. Can be called manually.
117- func triggerSync( ) async throws {
117+ public func triggerSync( ) async throws {
118118 try guardClosed ( )
119119 syncTriggerSubject. send ( ( ) )
120120 }
121121
122122 /// Deletes attachments marked as archived that exist on local storage.
123123 ///
124124 /// - Returns: `true` if any deletions occurred, `false` otherwise.
125- func deleteArchivedAttachments( _ context: AttachmentContext ) async throws -> Bool {
125+ public func deleteArchivedAttachments( _ context: AttachmentContext ) async throws -> Bool {
126126 return try await context. deleteArchivedAttachments { pendingDelete in
127127 for attachment in pendingDelete {
128128 guard let localUri = attachment. localUri else { continue }
@@ -149,7 +149,7 @@ actor SyncingServiceImpl: SyncingService {
149149 . sink { _ in continuation. yield ( ( ) ) }
150150
151151 continuation. onTermination = { _ in
152- continuation . finish ( )
152+ cancellable . cancel ( )
153153 }
154154 self . cancellables. insert ( cancellable)
155155 }
0 commit comments