Skip to content

armgit / ente

Public Imported from GitHub
0

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

change cache put write func to use stream writer

Abhinav2293939cbd13
diff --git a/src/services/diskCache.ts b/src/services/diskCache.ts
index 8f89a2093d..bd3baf7d70 100644
--- a/src/services/diskCache.ts
+++ b/src/services/diskCache.ts
@@ -1,9 +1,10 @@
import DiskLRUService from '../services/diskLRU';
import crypto from 'crypto';
-import { existsSync, readFile, writeFile, unlink } from 'promise-fs';
+import { existsSync, readFile, unlink } from 'promise-fs';
import path from 'path';
import { LimitedCache } from '../types/cache';
import { logError } from './logging';
+import { writeStream } from './fs';
const DEFAULT_CACHE_LIMIT = 1000 * 1000 * 1000; // 1GB
@@ -15,10 +16,7 @@ export class DiskCache implements LimitedCache {
async put(cacheKey: string, response: Response): Promise<void> {
const cachePath = path.join(this.cacheBucketDir, cacheKey);
- await writeFile(
- cachePath,
- new Uint8Array(await response.arrayBuffer())
- );
+ await writeStream(cachePath, response.body);
DiskLRUService.enforceCacheSizeLimit(
this.cacheBucketDir,
this.cacheLimit