From 887debcae4916f2db55aac5ad84cdb27cfb684a5 Mon Sep 17 00:00:00 2001 From: Shawn Date: Tue, 24 Sep 2024 13:07:45 -0400 Subject: [PATCH] more comments --- src/index.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/index.ts b/src/index.ts index cb51352..07f7222 100644 --- a/src/index.ts +++ b/src/index.ts @@ -330,8 +330,15 @@ async function main() { const newDir = `${path.resolve(syncConfig.local_path)}-${work.id}`; log.info(`Moving ${syncConfig.local_path} to ${newDir} for upload`); try { + /** + * Try moving the folder, because it's faster than copying. + */ await fs.rename(syncConfig.local_path, newDir); } catch (e: any) { + /** + * If the move fails, it's likely due to a cross-device link error, + * so we should copy the folder instead. + */ if (e.code && e.code === "EXDEV") { log.warn( `Cannot move ${syncConfig.local_path} to ${newDir} due to cross-device link, copying instead`