async function syncFromRemote() {
  try {
    /** 1. Get remote updated files */
    const files = await findRemoteUpdatedFiles(ADMIN_USER_ID);
    if (!files || files.length === 0) return Promise.resolve(true);
    if (!Array.isArray(files))
      throw new Error(`files - ${files} is not an array.`);

    /** 2. download the files */
    await downloadMultipleFromS3(
      S3_BUCKET_NAME,
      files.map(({ fullPath }) => fullPath)
    );

    /** 3. Update files' remoteUpdated flag to 0 */
    const isUpdated = await toggleFilesRemoteUpdatedFlag(
      files.map(({ fullPath }) => fullPath)
    );

    return Promise.resolve(isUpdated);
  } catch (err) {
    throw new Error(`Error occurs in syncFromRemote: ${err.message}`);
  }
}
/** syncFromRemote donwload remote updated files to local repository and
 * update the database files remoteUpdated flag back to 0
 * 1. get remoteUpdated files
 * 2. donwload file from S3 with the s3 file path to local dirname of the file path
 * 3. Update files' remoteUpdated flag to 0
 * @return Promise<Boolean>
 */
syncFromRemote donwload remote updated files to local repository and
update the database files remoteUpdated flag back to 0
1. get remoteUpdated files
2. donwload file from S3 with the s3 file path to local dirname of the file path
3. Update files' remoteUpdated flag to 0
@return Promise
syncFromRemote donwload remote updated files to local repository and update the database files remoteUpdated flag back to 0 1 . get remoteUpdated files 2 . donwload file from S3 with the s3 file path to local dirname of the file path 3 . Update files ' remoteUpdated flag to 0 @return Promise
async function syncFromRemote() {
  try {
    const files = await findRemoteUpdatedFiles(ADMIN_USER_ID);
    if (!files || files.length === 0) return Promise.resolve(true);
    if (!Array.isArray(files))
      throw new Error(`files - ${files} is not an array.`);
    await downloadMultipleFromS3(
      S3_BUCKET_NAME,
      files.map(({ fullPath }) => fullPath)
    );
    const isUpdated = await toggleFilesRemoteUpdatedFlag(
      files.map(({ fullPath }) => fullPath)
    );
    return Promise.resolve(isUpdated);
  } catch (err) {
    throw new Error(`Error occurs in syncFromRemote: ${err.message}`);
  }
}
async function syncFromRemote ( ) { try { const files = await findRemoteUpdatedFiles ( ADMIN_USER_ID ) ; if ( ! files || files . length === 0 ) return Promise . resolve ( true ) ; if ( ! Array . isArray ( files ) ) throw new Error ( ` ${ files } ` ) ; await downloadMultipleFromS3 ( S3_BUCKET_NAME , files . map ( ( { fullPath } ) => fullPath ) ) ; const isUpdated = await toggleFilesRemoteUpdatedFlag ( files . map ( ( { fullPath } ) => fullPath ) ) ; return Promise . resolve ( isUpdated ) ; } catch ( err ) { throw new Error ( ` ${ err . message } ` ) ; } }
syncFromRemote donwload remote updated files to local repository and
 update the database files remoteUpdated flag back to 0
 1. get remoteUpdated files
 2. donwload file from S3 with the s3 file path to local dirname of the file path
 3.
syncFromRemote donwload remote updated files to local repository and update the database files remoteUpdated flag back to 0 1 . get remoteUpdated files 2 . donwload file from S3 with the s3 file path to local dirname of the file path 3 .
/** 1. Get remote updated files */ /** 2. download the files */ /** 3. Update files' remoteUpdated flag to 0 */