Fix crash in files cache
authorChocobozzz <me@florianbigard.com>
Tue, 28 May 2019 07:36:46 +0000 (09:36 +0200)
committerChocobozzz <me@florianbigard.com>
Tue, 28 May 2019 07:36:46 +0000 (09:36 +0200)
server/lib/files-cache/abstract-video-static-file-cache.ts

index 1908cfb06f12959c117ab84327aeb53a125bee34..c06355446c73fc73cb0da0952f97d9494e2da84c 100644 (file)
@@ -18,8 +18,8 @@ export abstract class AbstractVideoStaticFileCache <T> {
       maxAge,
       max,
       promise: true,
-      dispose: (result: GetFilePathResult) => {
-        if (result.isOwned !== true) {
+      dispose: (result?: GetFilePathResult) => {
+        if (result && result.isOwned !== true) {
           remove(result.path)
             .then(() => logger.debug('%s removed from %s', result.path, this.constructor.name))
             .catch(err => logger.error('Cannot remove %s from cache %s.', result.path, this.constructor.name, { err }))