瀏覽代碼

@uppy/core: fix TypeError in event handler when file was removed (#3629)

Antoine du Hamel 3 年之前
父節點
當前提交
cf749be6e5
共有 1 個文件被更改,包括 6 次插入6 次删除
  1. 6 6
      packages/@uppy/core/src/Uppy.js

+ 6 - 6
packages/@uppy/core/src/Uppy.js

@@ -979,7 +979,7 @@ class Uppy {
     })
 
     this.on('upload-started', (file) => {
-      if (!this.getFile(file.id)) {
+      if (file == null || !this.getFile(file.id)) {
         this.log(`Not setting progress for a file that has been removed: ${file.id}`)
         return
       }
@@ -997,7 +997,7 @@ class Uppy {
     this.on('upload-progress', this.calculateProgress)
 
     this.on('upload-success', (file, uploadResp) => {
-      if (!this.getFile(file.id)) {
+      if (file == null || !this.getFile(file.id)) {
         this.log(`Not setting progress for a file that has been removed: ${file.id}`)
         return
       }
@@ -1030,7 +1030,7 @@ class Uppy {
     })
 
     this.on('preprocess-progress', (file, progress) => {
-      if (!this.getFile(file.id)) {
+      if (file == null || !this.getFile(file.id)) {
         this.log(`Not setting progress for a file that has been removed: ${file.id}`)
         return
       }
@@ -1040,7 +1040,7 @@ class Uppy {
     })
 
     this.on('preprocess-complete', (file) => {
-      if (!this.getFile(file.id)) {
+      if (file == null || !this.getFile(file.id)) {
         this.log(`Not setting progress for a file that has been removed: ${file.id}`)
         return
       }
@@ -1052,7 +1052,7 @@ class Uppy {
     })
 
     this.on('postprocess-progress', (file, progress) => {
-      if (!this.getFile(file.id)) {
+      if (file == null || !this.getFile(file.id)) {
         this.log(`Not setting progress for a file that has been removed: ${file.id}`)
         return
       }
@@ -1062,7 +1062,7 @@ class Uppy {
     })
 
     this.on('postprocess-complete', (file) => {
-      if (!this.getFile(file.id)) {
+      if (file == null || !this.getFile(file.id)) {
         this.log(`Not setting progress for a file that has been removed: ${file.id}`)
         return
       }