Quellcode durchsuchen

fix(Downloaders): fix useCaches option

evshiron vor 8 Jahren
Ursprung
Commit
f831d93ef3
2 geänderte Dateien mit 24 neuen und 4 gelöschten Zeilen
  1. 12 2
      src/lib/Downloader.ts
  2. 12 2
      src/lib/FFmpegDownloader.ts

+ 12 - 2
src/lib/Downloader.ts

@@ -61,8 +61,18 @@ export class Downloader extends DownloaderBase {
         debug('in fetch', 'filename', filename);
         debug('in fetch', 'path', path);
 
-        if(await this.isFileExists(path) && await this.isFileSynced(url, path)) {
-            return path;
+        try {
+            if(await this.isFileExists(path) && await this.isFileSynced(url, path)) {
+                return path;
+            }
+        }
+        catch(err) {
+            if(err.code === 'ENOTFOUND' && this.options.useCaches) {
+                return path;
+            }
+            else {
+                throw err;
+            }
         }
 
         await this.download(url, filename, path, showProgress);

+ 12 - 2
src/lib/FFmpegDownloader.ts

@@ -70,8 +70,18 @@ export class FFmpegDownloader extends DownloaderBase {
         debug('in fetch', 'filename', filename);
         debug('in fetch', 'path', path);
 
-        if(await this.isFileExists(path) && await this.isFileSynced(url, path)) {
-            return path;
+        try {
+            if(await this.isFileExists(path) && await this.isFileSynced(url, path)) {
+                return path;
+            }
+        }
+        catch(err) {
+            if(err.code === 'ENOTFOUND' && this.options.useCaches) {
+                return path;
+            }
+            else {
+                throw err;
+            }
         }
 
         await this.download(url, filename, path, showProgress);