diff --git a/server/routes/objects.js b/server/routes/objects.js index 34a64a49..b81127d6 100644 --- a/server/routes/objects.js +++ b/server/routes/objects.js @@ -55,7 +55,6 @@ router.get("/:url", async (req, res) => { }); } const objects = []; - // console.log(user); const stream = minioClient.listObjects( bucketName, "hv/" + user + "/thumbnail", @@ -78,7 +77,6 @@ router.get("/:url", async (req, res) => { let tname = name.split("/")[3]; await file_stats(bucketName, tname.split(".")[0]).then( (response) => { - // console.log(response); if (response[0]?.isUploaded) temp.push({ name: tname.split(".")[0], @@ -109,9 +107,7 @@ const handleUpload = async ( fileName, socketIndex ) => { - // console.log(sockets,socketIndex) let sock = sockets[socketIndex].sock; - // console.log(bucketName+minioPath+filePath) minioClient.fPutObject( bucketName, minioPath + filePath, @@ -120,6 +116,7 @@ const handleUpload = async ( if (err) { console.error("---->", err); } else { + // console.log("file-path ->",filePath) console.log(count++); obj.curr_count++; if (sock != 0 && obj.curr_count % 10 == 0) { @@ -167,7 +164,7 @@ const handleUpload = async ( fs.unlinkSync(dziPath); } } - // sem.leave(1) + sem.leave(1) } ); }; @@ -180,7 +177,6 @@ const handleAllUpload = async ( format, tempDirPath ) => { - // console.log("user--",user); let obj = { total_files: 0, curr_count: 0, @@ -200,21 +196,23 @@ const handleAllUpload = async ( walker = walk(`temp/${fileName}_files`); let filePath; + let cnt = 0; + walker.on("file", async (root, fileStats, next) => { - filePath = root + "/" + fileStats.name; - // sem.take(1,() => handleUpload(bucketName,minioPath,filePath,obj,tempDirPath,fileName)) - // console.log(minioPath,filePath) - handleUpload( - bucketName, - minioPath, - filePath, - obj, - tempDirPath, - fileName, - sock - ); + cnt++; + const filePath = root + "/" + fileStats.name; + try { + await new Promise((resolve) => { + sem.take(1, () => resolve(handleUpload(bucketName, minioPath, filePath, obj, tempDirPath, fileName, sock))); + }); + } catch (error) { + // Handle any errors that occurred during handleUpload + console.error("Error during handleUpload:", error); + } + next(); }); + walker.on("end", () => { console.log("End Upload"); @@ -285,6 +283,11 @@ router.post("/:url", async function (req, res) { filePath, `./temp/${tempName}`, "--vips-progress", + // "--tile-size", + // "350" + // "--depth", + // "onetile", + // "--overlap=1", ]; // Add any arguments your command requires const childProcess = spawn(command, args);