@uppy/core
Advanced tools
Comparing version
# @uppy/core | ||
## 4.4.3 | ||
Released: 2025-03-13 | ||
Included in: Uppy v4.13.4 | ||
- @uppy/core: make upload() idempotent (Merlijn Vos / #5677) | ||
## 4.4.2 | ||
@@ -4,0 +11,0 @@ |
@@ -24,3 +24,3 @@ function _classPrivateFieldLooseBase(e, t) { if (!{}.hasOwnProperty.call(e, t)) throw new TypeError("attempted to use private field on non-instance"); return e; } | ||
const packageJson = { | ||
"version": "4.4.2" | ||
"version": "4.4.3" | ||
}; | ||
@@ -1182,3 +1182,3 @@ import locale from './locale.js'; | ||
*/ | ||
upload() { | ||
async upload() { | ||
var _classPrivateFieldLoo; | ||
@@ -1191,2 +1191,36 @@ if (!((_classPrivateFieldLoo = _classPrivateFieldLooseBase(this, _plugins)[_plugins]['uploader']) != null && _classPrivateFieldLoo.length)) { | ||
} = this.getState(); | ||
// Check if we have files with errors (for retry behavior) | ||
const filesToRetry = Object.keys(files).filter(fileID => files[fileID].error); | ||
const hasFilesToRetry = filesToRetry.length > 0; | ||
// If we have files to retry, behave like retryAll() and ignore any new files | ||
if (hasFilesToRetry) { | ||
const updatedFiles = { | ||
...files | ||
}; | ||
filesToRetry.forEach(fileID => { | ||
updatedFiles[fileID] = { | ||
...updatedFiles[fileID], | ||
isPaused: false, | ||
error: null | ||
}; | ||
}); | ||
this.setState({ | ||
files: updatedFiles, | ||
error: null | ||
}); | ||
this.emit('retry-all', Object.values(updatedFiles)); | ||
const uploadID = _classPrivateFieldLooseBase(this, _createUpload)[_createUpload](filesToRetry, { | ||
forceAllowNewUpload: true // create new upload even if allowNewUpload: false | ||
}); | ||
const result = await _classPrivateFieldLooseBase(this, _runUpload)[_runUpload](uploadID); | ||
const hasNewFiles = this.getFiles().filter(file => file.progress.uploadStarted == null); | ||
if (!hasNewFiles) { | ||
return result; | ||
} | ||
files = this.getState().files; | ||
} | ||
// If no files to retry, proceed with original upload() behavior for new files | ||
const onBeforeUploadResult = this.opts.onBeforeUpload(files); | ||
@@ -1193,0 +1227,0 @@ if (onBeforeUploadResult === false) { |
{ | ||
"name": "@uppy/core", | ||
"description": "Core module for the extensible JavaScript file upload widget with support for drag&drop, resumable uploads, previews, restrictions, file processing/encoding, remote providers like Instagram, Dropbox, Google Drive, S3 and more :dog:", | ||
"version": "4.4.2", | ||
"version": "4.4.3", | ||
"license": "MIT", | ||
@@ -36,4 +36,4 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"vitest": "^1.2.1" | ||
"vitest": "^1.6.1" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
540972
1.2%8722
1.22%