Skip to content

Commit

Permalink
Merge pull request #16 from penwern/fix-multipart-checksums
Browse files Browse the repository at this point in the history
cache bust workers
  • Loading branch information
Sunday-Crunk authored Nov 19, 2024
2 parents 94e451c + b0ef6be commit 15574bf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/js/core/WorkerManager.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import HashWorker from "../workers/hashWorker.worker.js";

class CurateWorkerManager {
constructor() {
this.taskQueue = [];
Expand All @@ -11,8 +13,8 @@ class CurateWorkerManager {
}

// Load the worker from jsDelivr
const workerUrl = "/workers/hashWorker.js";
this.worker = new Worker(workerUrl);

this.worker = new HashWorker();
console.log("Worker initialized: ", this.worker);
this.setupWorkerHandlers();
}
Expand Down
4 changes: 2 additions & 2 deletions src/js/workers/hashWorker.worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ self.onmessage = async function (event) {
file,
multipartThreshold
);
postMessage({ status: "complete1", hash: finalChecksum });
postMessage({ status: "complete", hash: finalChecksum });
} catch (error) {
postMessage({ status: "error", message: error.message });
}
} else {
// Use the original checksum process for small files (no multipart)
const gmd5 = await incrementalMD5(file);
postMessage({ status: "complete2", hash: gmd5 });
postMessage({ status: "complete", hash: gmd5 });
}
self.close();
}
Expand Down
7 changes: 6 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@ module.exports = {
{
test: /\.worker\.js$/,
include: [path.resolve(__dirname, "src/js/workers")],
use: { loader: "worker-loader" },
use: {
loader: "worker-loader",
options: {
filename: "[name].[hash].worker.js",
},
},
},
],
},
Expand Down

0 comments on commit 15574bf

Please sign in to comment.