-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dry retryAll() and upload() #5691
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
improvement of #5677
Diff output filesdiff --git a/packages/@uppy/core/lib/Uppy.js b/packages/@uppy/core/lib/Uppy.js
index 3411f74..aa33ea6 100644
--- a/packages/@uppy/core/lib/Uppy.js
+++ b/packages/@uppy/core/lib/Uppy.js
@@ -42,6 +42,8 @@ var _assertNewUploadAllowed = _classPrivateFieldLooseKey("assertNewUploadAllowed
var _transformFile = _classPrivateFieldLooseKey("transformFile");
var _startIfAutoProceed = _classPrivateFieldLooseKey("startIfAutoProceed");
var _checkAndUpdateFileState = _classPrivateFieldLooseKey("checkAndUpdateFileState");
+var _getFilesToRetry = _classPrivateFieldLooseKey("getFilesToRetry");
+var _doRetryAll = _classPrivateFieldLooseKey("doRetryAll");
var _handleUploadProgress = _classPrivateFieldLooseKey("handleUploadProgress");
var _updateTotalProgress = _classPrivateFieldLooseKey("updateTotalProgress");
var _updateTotalProgressThrottled = _classPrivateFieldLooseKey("updateTotalProgressThrottled");
@@ -76,6 +78,12 @@ export class Uppy {
Object.defineProperty(this, _updateTotalProgress, {
value: _updateTotalProgress2,
});
+ Object.defineProperty(this, _doRetryAll, {
+ value: _doRetryAll2,
+ });
+ Object.defineProperty(this, _getFilesToRetry, {
+ value: _getFilesToRetry2,
+ });
Object.defineProperty(this, _checkAndUpdateFileState, {
value: _checkAndUpdateFileState2,
});
@@ -730,35 +738,7 @@ export class Uppy {
this.emit("resume-all");
}
async retryAll() {
- const updatedFiles = {
- ...this.getState().files,
- };
- const filesToRetry = Object.keys(updatedFiles).filter(file => {
- return updatedFiles[file].error;
- });
- filesToRetry.forEach(file => {
- const updatedFile = {
- ...updatedFiles[file],
- isPaused: false,
- error: null,
- };
- updatedFiles[file] = updatedFile;
- });
- this.setState({
- files: updatedFiles,
- error: null,
- });
- this.emit("retry-all", Object.values(updatedFiles));
- if (filesToRetry.length === 0) {
- return Promise.resolve({
- successful: [],
- failed: [],
- });
- }
- const uploadID = _classPrivateFieldLooseBase(this, _createUpload)[_createUpload](filesToRetry, {
- forceAllowNewUpload: true,
- });
- const result = await _classPrivateFieldLooseBase(this, _runUpload)[_runUpload](uploadID);
+ const result = await _classPrivateFieldLooseBase(this, _doRetryAll)[_doRetryAll]();
this.emit("complete", result);
return result;
}
@@ -996,34 +976,18 @@ export class Uppy {
let {
files,
} = this.getState();
- const filesToRetry = Object.keys(files).filter(fileID => files[fileID].error);
- const hasFilesToRetry = filesToRetry.length > 0;
- 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", this.getFilesByIds(filesToRetry));
- const uploadID = _classPrivateFieldLooseBase(this, _createUpload)[_createUpload](filesToRetry, {
- forceAllowNewUpload: true,
- });
- const result = await _classPrivateFieldLooseBase(this, _runUpload)[_runUpload](uploadID);
+ const filesToRetry = _classPrivateFieldLooseBase(this, _getFilesToRetry)[_getFilesToRetry]();
+ if (filesToRetry.length > 0) {
+ const retryResult = await _classPrivateFieldLooseBase(this, _doRetryAll)[_doRetryAll]();
const hasNewFiles = this.getFiles().filter(file => file.progress.uploadStarted == null).length > 0;
if (!hasNewFiles) {
- this.emit("complete", result);
- return result;
+ this.emit("complete", retryResult);
+ return retryResult;
}
- files = this.getState().files;
+
+ ({
+ files,
+ } = this.getState());
}
const onBeforeUploadResult = this.opts.onBeforeUpload(files);
if (onBeforeUploadResult === false) {
@@ -1265,6 +1229,42 @@ function _checkAndUpdateFileState2(filesToAdd) {
errors,
};
}
+function _getFilesToRetry2() {
+ const {
+ files,
+ } = this.getState();
+ return Object.keys(files).filter(file => {
+ return files[file].error;
+ });
+}
+async function _doRetryAll2() {
+ const filesToRetry = _classPrivateFieldLooseBase(this, _getFilesToRetry)[_getFilesToRetry]();
+ const updatedFiles = {
+ ...this.getState().files,
+ };
+ filesToRetry.forEach(fileID => {
+ updatedFiles[fileID] = {
+ ...updatedFiles[fileID],
+ isPaused: false,
+ error: null,
+ };
+ });
+ this.setState({
+ files: updatedFiles,
+ error: null,
+ });
+ this.emit("retry-all", this.getFilesByIds(filesToRetry));
+ if (filesToRetry.length === 0) {
+ return {
+ successful: [],
+ failed: [],
+ };
+ }
+ const uploadID = _classPrivateFieldLooseBase(this, _createUpload)[_createUpload](filesToRetry, {
+ forceAllowNewUpload: true,
+ });
+ return _classPrivateFieldLooseBase(this, _runUpload)[_runUpload](uploadID);
+}
function _updateTotalProgress2() {
var _totalProgressPercent, _totalProgressPercent2;
const totalProgress = _classPrivateFieldLooseBase(this, _calculateTotalProgress)[_calculateTotalProgress](); |
This has some conflicts now after the fix #5696 |
# Conflicts: # packages/@uppy/core/src/Uppy.ts
Murderlon
approved these changes
Apr 8, 2025
github-actions bot
added a commit
that referenced
this pull request
Apr 8, 2025
| Package | Version | Package | Version | | -------------------------- | ------- | -------------------------- | ------- | | @uppy/audio | 2.1.2 | @uppy/locales | 4.5.2 | | @uppy/box | 3.2.2 | @uppy/onedrive | 4.2.3 | | @uppy/companion | 5.6.0 | @uppy/react | 4.2.3 | | @uppy/core | 4.4.4 | @uppy/remote-sources | 2.3.2 | | @uppy/dashboard | 4.3.3 | @uppy/screen-capture | 4.2.2 | | @uppy/drag-drop | 4.1.2 | @uppy/status-bar | 4.1.3 | | @uppy/dropbox | 4.2.2 | @uppy/transloadit | 4.2.2 | | @uppy/facebook | 4.2.2 | @uppy/unsplash | 4.3.3 | | @uppy/file-input | 4.1.2 | @uppy/url | 4.2.3 | | @uppy/google-drive | 4.3.2 | @uppy/utils | 6.1.3 | | @uppy/google-drive-picker | 0.3.4 | @uppy/webcam | 4.1.2 | | @uppy/google-photos-picker | 0.3.4 | @uppy/webdav | 0.3.2 | | @uppy/image-editor | 3.3.2 | @uppy/zoom | 3.2.2 | | @uppy/instagram | 4.2.2 | uppy | 4.14.0 | - @uppy/core: dry retryAll() and upload() (Mikael Finstad / #5691) - @uppy/angular: Revert "Support Angular 19" (Mikael Finstad / #5710) - @uppy/angular: Support Angular 19 (Arnaud Flaesch / #5709) - @uppy/companion: implement dropbox business teams (Mikael Finstad / #5708) - @uppy/utils: add msg mimetype (Merlijn Vos / #5699) - @uppy/core: fix locale type for plugins (Merlijn Vos / #5700) - examples: build(deps-dev): bump vite from 5.4.14 to 5.4.15 (dependabot[bot] / #5703) - @uppy/locales: Update nb_NO.ts (Tore Sinding Bekkedal / #5678) - meta: build(deps): bump docker/login-action from 3.3.0 to 3.4.0 (dependabot[bot] / #5689) - examples: @uppy-example/aws-nodejs: fix fileType not present in S3 objects (Prakash / #5680) - @uppy/core: fix events when retrying with upload() (Prakash / #5696) - meta: Fix locales building (Mikael Finstad / #5693) - @uppy/google-photos: remove google photos 😢 (Mikael Finstad / #5690) - @uppy/locales: Update cs_CZ.ts (David Petrásek / #5658)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
improvement of #5677