11import { AbstractPowerSyncDatabase , DifferentialWatchedQuery , ILogger , Transaction } from '@powersync/common' ;
22import { AttachmentContext } from './AttachmentContext.js' ;
3- import { LocalStorageAdapter } from './LocalStorageAdapter.js' ;
3+ import { AttachmentData , LocalStorageAdapter } from './LocalStorageAdapter.js' ;
44import { RemoteStorageAdapter } from './RemoteStorageAdapter.js' ;
55import { ATTACHMENT_TABLE , AttachmentRecord , AttachmentState } from './Schema.js' ;
66import { SyncingService } from './SyncingService.js' ;
77import { WatchedAttachmentItem } from './WatchedAttachmentItem.js' ;
88import { AttachmentService } from './AttachmentService.js' ;
99
10- export type AttachmentData = ArrayBuffer | Blob | string ;
11-
1210/**
1311 * AttachmentQueue manages the lifecycle and synchronization of attachments
1412 * between local and remote storage.
@@ -96,7 +94,6 @@ export class AttachmentQueue {
9694 downloadAttachments ?: boolean ;
9795 archivedCacheLimit ?: number ;
9896 } ) {
99- console . debug ( 'AttachmentQueue constructor' )
10097 this . context = new AttachmentContext ( db , tableName , logger ?? db . logger ) ;
10198 this . remoteStorage = remoteStorage ;
10299 this . localStorage = localStorage ;
@@ -136,7 +133,6 @@ export class AttachmentQueue {
136133 * - Handles state transitions for archived and new attachments
137134 */
138135 async startSync ( ) : Promise < void > {
139- console . debug ( '[QUEUE] AttachmentQueue startSync' )
140136 if ( this . attachmentService . watchActiveAttachments ) {
141137 await this . stopSync ( ) ;
142138 // re-create the watch after it was stopped
@@ -151,14 +147,12 @@ export class AttachmentQueue {
151147 // Sync storage when there is a change in active attachments
152148 this . watchActiveAttachments . registerListener ( {
153149 onDiff : async ( ) => {
154- console . debug ( '[QUEUE] watchActiveAttachments: diff detected, syncing storage' ) ;
155150 await this . syncStorage ( ) ;
156151 }
157152 } ) ;
158153
159154 // Process attachments when there is a change in watched attachments
160155 this . watchAttachments ( async ( watchedAttachments ) => {
161- console . debug ( '[QUEUE] watchAttachments callback:' , watchedAttachments . length , 'items' ) ;
162156 // Need to get all the attachments which are tracked in the DB.
163157 // We might need to restore an archived attachment.
164158 const currentAttachments = await this . context . getAttachments ( ) ;
@@ -234,7 +228,6 @@ export class AttachmentQueue {
234228 }
235229
236230 if ( attachmentUpdates . length > 0 ) {
237- console . debug ( '[QUEUE] Saving attachments:' , attachmentUpdates ) ;
238231 await this . context . saveAttachments ( attachmentUpdates ) ;
239232 }
240233 } ) ;
@@ -248,7 +241,6 @@ export class AttachmentQueue {
248241 */
249242 async syncStorage ( ) : Promise < void > {
250243 const activeAttachments = await this . context . getActiveAttachments ( ) ;
251- console . debug ( '[QUEUE] syncStorage: processing' , activeAttachments . length , 'active attachments' ) ;
252244 await this . localStorage . initialize ( ) ;
253245 await this . syncingService . processAttachments ( activeAttachments ) ;
254246 await this . syncingService . deleteArchivedAttachments ( ) ;
0 commit comments