Skip to content
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

@uppy/transloadit: remove updateNumberOfFilesInAssembly #5202

Merged
merged 1 commit into from
May 29, 2024

Conversation

Murderlon
Copy link
Member

  • If you haven't started the upload yet, this is unneeded.
  • If you did start the upload and you try to removeFile(s), Uppy throws an error that individualCancellation is not supported
  • If you remove files after the upload is complete, the API returns a 404 for /update_assemblies (which was a bug in itself, trying to call this after the assembly is done).

Internally it was also brought up that /update_assemblies is not something we want to publicly expose.

@Murderlon Murderlon requested review from mifi and aduh95 May 28, 2024 17:08
@Murderlon Murderlon self-assigned this May 28, 2024
Copy link
Contributor

Diff output files
diff --git a/packages/@uppy/transloadit/lib/Client.js b/packages/@uppy/transloadit/lib/Client.js
index 798d3da..664510d 100644
--- a/packages/@uppy/transloadit/lib/Client.js
+++ b/packages/@uppy/transloadit/lib/Client.js
@@ -126,26 +126,6 @@ export default class Client {
       })
     );
   }
-  async updateNumberOfFilesInAssembly(assembly, num_expected_upload_files) {
-    const url = new URL(assembly.assembly_ssl_url);
-    url.pathname = "/update_assemblies";
-    const body = JSON.stringify({
-      assembly_updates: [{
-        assembly_id: assembly.assembly_id,
-        num_expected_upload_files,
-      }],
-    });
-    return _classPrivateFieldLooseBase(this, _fetchJSON)[_fetchJSON](url, {
-      method: "POST",
-      headers: _classPrivateFieldLooseBase(this, _headers)[_headers],
-      body,
-    }).catch(err =>
-      _classPrivateFieldLooseBase(this, _reportError)[_reportError](err, {
-        url,
-        type: "API_ERROR",
-      })
-    );
-  }
   async cancelAssembly(assembly) {
     const url = assembly.assembly_ssl_url;
     return _classPrivateFieldLooseBase(this, _fetchJSON)[_fetchJSON](url, {
diff --git a/packages/@uppy/transloadit/lib/index.js b/packages/@uppy/transloadit/lib/index.js
index e9f566d..fdc7ed7 100644
--- a/packages/@uppy/transloadit/lib/index.js
+++ b/packages/@uppy/transloadit/lib/index.js
@@ -593,12 +593,9 @@ function _createAssembly2(fileIDs, uploadID, assemblyOptions) {
       } = _ref2;
       return fileIDs.includes(id);
     });
-    if (files.length !== fileIDs.length) {
-      if (files.length === 0) {
-        await this.client.cancelAssembly(newAssembly);
-        return null;
-      }
-      await this.client.updateNumberOfFilesInAssembly(newAssembly, files.length);
+    if (files.length === 0) {
+      await this.client.cancelAssembly(newAssembly);
+      return null;
     }
     const assembly = new Assembly(newAssembly, _classPrivateFieldLooseBase(this, _rateLimitedQueue)[_rateLimitedQueue]);
     const {
@@ -641,10 +638,6 @@ function _createAssembly2(fileIDs, uploadID, assemblyOptions) {
       if (reason === "cancel-all") {
         assembly.close();
         this.uppy.off("file-removed", fileRemovedHandler);
-      } else if (fileRemoved.id in updatedFiles) {
-        delete updatedFiles[fileRemoved.id];
-        const nbOfRemainingFiles = Object.keys(updatedFiles).length;
-        this.client.updateNumberOfFilesInAssembly(newAssembly, nbOfRemainingFiles).catch(() => {});
       }
     };
     this.uppy.on("file-removed", fileRemovedHandler);

@Murderlon Murderlon merged commit fe0437a into main May 29, 2024
17 checks passed
@Murderlon Murderlon deleted the update-files-assembly branch May 29, 2024 12:44
@github-actions github-actions bot mentioned this pull request Jun 4, 2024
github-actions bot added a commit that referenced this pull request Jun 4, 2024
| Package                | Version | Package                | Version |
| ---------------------- | ------- | ---------------------- | ------- |
| @uppy/aws-s3-multipart |  3.12.0 | @uppy/webcam           |   3.4.2 |
| @uppy/core             |  3.12.0 | uppy                   |  3.26.0 |
| @uppy/transloadit      |   3.7.0 |                        |         |

- meta: remove Companion's `prepublishOnly` (Mikael Finstad / #5220)
- docs: document clearUploadedFiles (Merlijn Vos / #5204)
- @uppy/webcam: add missing types for `recordedVideo` (Antoine du Hamel / #5208)
- @uppy/core: check capabilities in clearUploadedFiles (Merlijn Vos / #5201)
- @uppy/core: PartialTree - change the `maxTotalFileSize` error (Evgenia Karunus / #5203)
- @uppy/transloadit: remove `updateNumberOfFilesInAssembly` (Merlijn Vos / #5202)
- @uppy/aws-s3: resolve all headers on response (Merlijn Vos / #5195)
- docs: Improve provider docs: OneDrive (Evgenia Karunus / #5196)
Murderlon added a commit that referenced this pull request Jun 5, 2024
* 4.x:
  meta: fix AWS test suite (#5229)
  Release: uppy@4.0.0-beta.10 (#5225)
  Release: uppy@3.26.0 (#5223)
  meta: remove Companion's `prepublishOnly` (#5220)
  docs: document clearUploadedFiles (#5204)
  @uppy/webcam: add missing types for `recordedVideo` (#5208)
  @uppy/core: check capabilities in clearUploadedFiles (#5201)
  PartialTree - change the `maxTotalFileSize` error (#5203)
  @uppy/transloadit: remove `updateNumberOfFilesInAssembly` (#5202)
  @uppy/aws-s3: resolve all headers on response (#5195)
  Improve provider docs: OneDrive (#5196)
Murderlon added a commit that referenced this pull request Jun 10, 2024
* main: (262 commits)
  Release: uppy@3.26.0 (#5223)
  meta: remove Companion's `prepublishOnly` (#5220)
  docs: document clearUploadedFiles (#5204)
  @uppy/webcam: add missing types for `recordedVideo` (#5208)
  @uppy/core: check capabilities in clearUploadedFiles (#5201)
  PartialTree - change the `maxTotalFileSize` error (#5203)
  @uppy/transloadit: remove `updateNumberOfFilesInAssembly` (#5202)
  @uppy/aws-s3: resolve all headers on response (#5195)
  Improve provider docs: OneDrive (#5196)
  Release: uppy@3.25.5 (#5193)
  @uppy/transloadit: do not cancel assembly when removing all files (#5191)
  @uppy/xhr-upload: fix regression for lowercase HTTP methods (#5179)
  meta: improve changelog generator (#5190)
  Release: uppy@3.25.4 (#5188)
  @uppy/svelte: do not attempt removing plugin before it's created (#5186)
  Update facebook.mdx
  fixup! @uppy/tus: fix no headers passed to companion if argument is a function (#5182)
  @uppy/tus: fix no headers passed to companion if argument is a function (#5182)
  @uppy/companion: fix google drive gsuite export large size (#5144)
  Improve provider docs: Box & Zoom (#5166)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants