Sfoglia il codice sorgente

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

Antoine du Hamel 3 anni fa
parent
commit
cf749be6e5
1 ha cambiato i file con 6 aggiunte e 6 eliminazioni
  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
       }