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