From ec4f39a3b8d583558e16041153c2d24c76029c32 Mon Sep 17 00:00:00 2001 From: jtsmedley <38006759+jtsmedley@users.noreply.github.com> Date: Tue, 17 Sep 2024 09:23:40 -0500 Subject: [PATCH] Add parsing to auto add / for MFS paths --- src/objectManager.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/objectManager.js b/src/objectManager.js index 14bd7f3..60e0469 100644 --- a/src/objectManager.js +++ b/src/objectManager.js @@ -133,7 +133,7 @@ class ObjectManager { * // Upload Directory * await objectManager.upload("my-first-directory", [ * { - * path: "/testObjects/1.txt", + * path: "/testObjects/1.txt", // Virtual Path to store contents at within IPFS Folder/Directory * content: Buffer.from("upload test object", "utf-8"), * }, * { @@ -212,8 +212,9 @@ class ObjectManager { } const task = (async () => { await queue.add(async () => { + const mfsPath = entry.path.startsWith('/') ? entry.path : `/${entry.path}`; uploadLogger.silly("SOURCE_IMPORT_STARTED", { - path: entry.path, + path: mfsPath, size: queue.size, }); @@ -247,9 +248,9 @@ class ObjectManager { } else { return; } - createdFiles.set(entry.path, createdFile); + createdFiles.set(mfsPath, createdFile); uploadLogger.verbose("SOURCE_IMPORT_COMPLETED", { - path: entry.path, + path: mfsPath, size: queue.size, }); } else { @@ -261,9 +262,9 @@ class ObjectManager { } else { return; } - createdFiles.set(entry.path, createdFile); + createdFiles.set(mfsPath, createdFile); uploadLogger.verbose("SOURCE_IMPORT_COMPLETED", { - path: entry.path, + path: mfsPath, size: queue.size, }); }