Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Balance ref counts

Manav Rathi171a8670a469
diff --git a/desktop/src/main/services/zip.ts b/desktop/src/main/services/zip.ts
index 5a7f4242f0..17a7205bce 100644
--- a/desktop/src/main/services/zip.ts
+++ b/desktop/src/main/services/zip.ts
@@ -65,9 +65,9 @@ export const markClosableZip = (zipPath: string) => {
*/
export const clearOpenZipCache = () => {
if (_refCount.size > 0) {
- const keys = JSON.stringify([..._refCount.keys()]);
+ const kvs = JSON.stringify([..._refCount.entries()]);
throw new Error(
- `Attempting to clear zip file cache when some items are still in use: ${keys}`,
+ `Attempting to clear zip file cache when some items are still in use: ${kvs}`,
);
}
_cache.clear();
diff --git a/desktop/src/main/stream.ts b/desktop/src/main/stream.ts
index 41c71285a9..261ab32a21 100644
--- a/desktop/src/main/stream.ts
+++ b/desktop/src/main/stream.ts
@@ -137,6 +137,10 @@ const handleReadZip = async (zipPath: string, entryName: string) => {
log.error("Error event for the writable end of zip stream", e);
});
+ nodeWritable.on("close", () => {
+ markClosableZip(zipPath);
+ });
+
// While it is documented that entry.time is the modification time,
// the units are not mentioned. By seeing the source code, we can
// verify that it is indeed epoch milliseconds. See `parseZipTime`