async function intitalFilesSyncExec() {
  const transaction = await sequelize.transaction();
  try {
    /** Update to DB first */
    await scanAllToDB(ROOT_PATH, {
      filterDirs: IGNORED_PATH
    });

    /** Upload to S3 */
    await syncToBucketExec(ROOT_PATH, S3_BUCKET_URL, {
      shouldDelete: true,
      isInitial: true
    });
    await transaction.commit();
    return Promise.resolve(true);
  } catch (err) {
    await transaction.rollback();
    throw new Error(`Error occurs in intitalFilesSyncExec - ${err.message}`);
  }
}
/** When app is initiated, sync all the files up to S3
 * aws s3 sync will manage the files sync (by file size and timestamp)
 */
When app is initiated, sync all the files up to S3
aws s3 sync will manage the files sync (by file size and timestamp)
When app is initiated sync all the files up to S3 aws s3 sync will manage the files sync ( by file size and timestamp )
async function intitalFilesSyncExec() {
  const transaction = await sequelize.transaction();
  try {
    await scanAllToDB(ROOT_PATH, {
      filterDirs: IGNORED_PATH
    });
    await syncToBucketExec(ROOT_PATH, S3_BUCKET_URL, {
      shouldDelete: true,
      isInitial: true
    });
    await transaction.commit();
    return Promise.resolve(true);
  } catch (err) {
    await transaction.rollback();
    throw new Error(`Error occurs in intitalFilesSyncExec - ${err.message}`);
  }
}
async function intitalFilesSyncExec ( ) { const transaction = await sequelize . transaction ( ) ; try { await scanAllToDB ( ROOT_PATH , { filterDirs : IGNORED_PATH } ) ; await syncToBucketExec ( ROOT_PATH , S3_BUCKET_URL , { shouldDelete : true , isInitial : true } ) ; await transaction . commit ( ) ; return Promise . resolve ( true ) ; } catch ( err ) { await transaction . rollback ( ) ; throw new Error ( ` ${ err . message } ` ) ; } }
When app is initiated, sync all the files up to S3
 aws s3 sync will manage the files sync (by file size and timestamp)
When app is initiated sync all the files up to S3 aws s3 sync will manage the files sync ( by file size and timestamp )
/** Update to DB first */ /** Upload to S3 */