@@ -59,8 +59,14 @@ const controller = {
5959 // parent + child bucket records already in COMS db
6060 const dbChildBuckets = await bucketService . searchChildBuckets ( parentBucket , false , userId ) ;
6161 let dbBuckets = [ parentBucket ] . concat ( dbChildBuckets ) ;
62+ log . info ( `Found ${ dbBuckets . length } bucket records in COMS db for parent bucketId ${ bucketId } ` ,
63+ { function : 'syncBucketRecursive' } ) ;
64+
6265 // 'folders' that exist below (and including) the parent 'folder' in S3
6366 const s3Response = await storageService . listAllObjectVersions ( { bucketId : bucketId , precisePath : false } ) ;
67+ log . info ( `Found ${ s3Response . Versions . length } object versions and ${ s3Response . DeleteMarkers . length }
68+ delete markers in S3 for bucketId ${ bucketId } ` , { function : 'syncBucketRecursive' } ) ;
69+
6470 const s3Keys = [ ...new Set ( [
6571 ...s3Response . DeleteMarkers . map ( object => formatS3KeyForCompare ( object . Key ) ) ,
6672 ...s3Response . Versions . map ( object => formatS3KeyForCompare ( object . Key ) ) ,
@@ -78,6 +84,7 @@ const controller = {
7884 userId ,
7985 trx
8086 ) ;
87+ log . info ( `${ syncedBuckets . length } buckets records synced` , { function : 'syncBucketRecursive' } ) ;
8188
8289 /**
8390 * Queue objects in all the folders for syncing
@@ -107,6 +114,8 @@ const controller = {
107114 const userId = await userService . getCurrentUserId ( getCurrentIdentity ( req . currentUser , SYSTEM_USER ) , SYSTEM_USER ) ;
108115
109116 const s3Objects = await storageService . listAllObjectVersions ( { bucketId : bucketId , filterLatest : true } ) ;
117+ log . info ( `Found ${ s3Objects . Versions . length } object versions and ${ s3Objects . DeleteMarkers . length }
118+ delete markers in S3 for bucketId ${ bucketId } ` , { function : 'syncBucketSingle' } ) ;
110119
111120 const response = await utils . trxWrapper ( async ( trx ) => {
112121 return this . queueObjectRecords ( [ bucket ] , s3Objects , userId , trx ) ;
@@ -139,6 +148,8 @@ const controller = {
139148 oldDbBuckets . map ( dbBucket =>
140149 bucketService . delete ( dbBucket . bucketId , trx )
141150 . then ( ( ) => {
151+ log . info ( `Deleted bucketId ${ dbBucket . bucketId } from COMS db as key ${ dbBucket . key } not found in S3` ,
152+ { function : 'syncBucketRecords' } ) ;
142153 dbBuckets = dbBuckets . filter ( b => b . bucketId !== dbBucket . bucketId ) ;
143154 } )
144155 )
@@ -161,6 +172,7 @@ const controller = {
161172 const newS3Keys = s3Keys . filter ( k => ! dbBuckets . map ( b => b . key ) . includes ( k ) ) ;
162173 await Promise . all (
163174 newS3Keys . map ( s3Key => {
175+ log . info ( `Creating new bucket record in COMS db for S3 key ${ s3Key } ` , { function : 'syncBucketRecords' } ) ;
164176 const data = {
165177 bucketName : s3Key . substring ( s3Key . lastIndexOf ( '/' ) + 1 ) ,
166178 accessKeyId : parentBucket . accessKeyId ,
@@ -204,6 +216,9 @@ const controller = {
204216 bucketId : dbBuckets . map ( b => b . bucketId )
205217 } , trx ) ;
206218
219+ log . info ( `Found ${ dbObjects . data . length } object records in COMS db for ${ dbBuckets . length } buckets` ,
220+ { function : 'queueObjectRecords' } ) ;
221+
207222 /**
208223 * merge arrays of objects from COMS db and S3 to form an array of jobs with format:
209224 * [ { path: '/images/img3.jpg', bucketId: '123' }, { path: '/images/album1/img1.jpg', bucketId: '456' } ]
@@ -239,6 +254,7 @@ const controller = {
239254
240255 // merge and remove duplicates
241256 const jobs = [ ...new Map ( objects . map ( o => [ o . path , o ] ) ) . values ( ) ] ;
257+ log . info ( `Prepared ${ jobs . length } jobs to enqueue to object queue` , { function : 'queueObjectRecords' } ) ;
242258
243259 // create jobs in COMS db object_queue for each object
244260 // update 'lastSyncRequestedDate' value in COMS db for each bucket
0 commit comments