Skip to content

armgit / ente

Public Imported from GitHub
0

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

Remove old migration path

Manav Rathi467acf2b8e8c
diff --git a/desktop/src/services/diskCache.ts b/desktop/src/services/diskCache.ts
index 6861bba9f8..1f4cd52934 100644
--- a/desktop/src/services/diskCache.ts
+++ b/desktop/src/services/diskCache.ts
@@ -1,6 +1,5 @@
-import crypto from "crypto";
import path from "path";
-import { existsSync, rename, stat, unlink } from "promise-fs";
+import { existsSync, stat, unlink } from "promise-fs";
import DiskLRUService from "../services/diskLRU";
import { LimitedCache } from "../types/cache";
import { getFileStream, writeStream } from "./fs";
@@ -44,28 +43,6 @@ export class DiskCache implements LimitedCache {
DiskLRUService.touch(cachePath);
return new Response(await getFileStream(cachePath));
} else {
- // add fallback for old cache keys
- const oldCachePath = getOldAssetCachePath(
- this.cacheBucketDir,
- cacheKey,
- );
- if (existsSync(oldCachePath)) {
- const fileStats = await stat(oldCachePath);
- if (sizeInBytes && fileStats.size !== sizeInBytes) {
- logError(
- Error(),
- "Old cache key exists but size does not match. Deleting cache key.",
- );
- unlink(oldCachePath).catch((e) => {
- if (e.code === "ENOENT") return;
- logError(e, "Failed to delete cache key");
- });
- return undefined;
- }
- const match = new Response(await getFileStream(oldCachePath));
- void migrateOldCacheKey(oldCachePath, cachePath);
- return match;
- }
return undefined;
}
}
@@ -79,20 +56,3 @@ export class DiskCache implements LimitedCache {
}
}
}
-
-function getOldAssetCachePath(cacheDir: string, cacheKey: string) {
- // hashing the key to prevent illegal filenames
- const cacheKeyHash = crypto
- .createHash("sha256")
- .update(cacheKey)
- .digest("hex");
- return path.join(cacheDir, cacheKeyHash);
-}
-
-async function migrateOldCacheKey(oldCacheKey: string, newCacheKey: string) {
- try {
- await rename(oldCacheKey, newCacheKey);
- } catch (e) {
- logError(e, "Failed to move cache key to new cache key");
- }
-}