Fix testing issues (#1506)

This commit is contained in:
Abhinav Kumar 2023-12-13 14:18:24 +05:30 committed by GitHub
commit 0780752c7d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -62,6 +62,7 @@ class DownloadManagerImpl {
private ready: boolean = false;
private downloadClient: DownloadClient;
private thumbnailCache?: LimitedCache;
// disk cache is only available on electron
private diskFileCache?: LimitedCache;
private cryptoWorker: Remote<DedicatedCryptoWorker>;
@ -174,7 +175,7 @@ class DownloadManagerImpl {
this.thumbnailCache
?.put(file.id.toString(), new Response(thumb))
.catch((e) => {
logError(e, 'cache put failed');
logError(e, 'thumb cache put failed');
// TODO: handle storage full exception.
});
return thumb;
@ -306,12 +307,14 @@ class DownloadManagerImpl {
onDownloadProgress
)
);
this.diskFileCache
?.put(file.id.toString(), encrypted.clone())
.catch((e) => {
logError(e, 'cache put failed');
// TODO: handle storage full exception.
});
if (this.diskFileCache) {
this.diskFileCache
.put(file.id.toString(), encrypted.clone())
.catch((e) => {
logError(e, 'file cache put failed');
// TODO: handle storage full exception.
});
}
}
this.clearDownloadProgress(file.id);
try {
@ -343,7 +346,13 @@ class DownloadManagerImpl {
let resp: Response = await this.getCachedFile(file);
if (!resp) {
resp = await this.downloadClient.downloadFileStream(file);
void this.diskFileCache.put(file.id.toString(), resp.clone());
if (this.diskFileCache) {
this.diskFileCache
.put(file.id.toString(), resp.clone())
.catch((e) => {
logError(e, 'file cache put failed');
});
}
}
const reader = resp.body.getReader();