Skip to content

Commit

Permalink
@uppy/transloadit: fix multiple upload batches & run again (#5478)
Browse files Browse the repository at this point in the history
* @uppy/transloadit: fix multiple upload batchs & run again

* Remove console.log
  • Loading branch information
Murderlon authored Sep 30, 2024
1 parent c952609 commit 20291e1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
5 changes: 5 additions & 0 deletions packages/@uppy/core/src/Uppy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,11 @@ export class Uppy<
...files[fileID].progress,
...defaultProgress,
},
// @ts-expect-error these typed are inserted
// into the namespace in their respective packages
// but core isn't ware of those
tus: undefined,
transloadit: undefined,
}
})

Expand Down
15 changes: 8 additions & 7 deletions packages/@uppy/transloadit/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -696,12 +696,13 @@ export default class Transloadit<
this.assembly = new Assembly(previousAssembly, this.#rateLimitedQueue)
this.assembly.status = previousAssembly
this.setPluginState({ files, results })
return files
}

// Set up the Assembly instances and AssemblyWatchers for existing Assemblies.
const restoreAssemblies = () => {
const restoreAssemblies = (ids: string[]) => {
this.#createAssemblyWatcher(previousAssembly.assembly_id)
this.#connectAssembly(this.assembly!)
this.#connectAssembly(this.assembly!, ids)
}

// Force-update Assembly to check for missed events.
Expand All @@ -711,8 +712,8 @@ export default class Transloadit<

// Restore all Assembly state.
this.restored = (async () => {
restoreState()
restoreAssemblies()
const files = restoreState()
restoreAssemblies(Object.keys(files))
await updateAssembly()
this.restored = null
})()
Expand All @@ -722,7 +723,7 @@ export default class Transloadit<
})
}

#connectAssembly(assembly: Assembly) {
#connectAssembly(assembly: Assembly, ids: UppyFile<M, B>['id'][]) {
const { status } = assembly
const id = status.assembly_id
this.assembly = assembly
Expand Down Expand Up @@ -754,7 +755,7 @@ export default class Transloadit<
// per-file progress as well. We cannot use this here or otherwise progress from
// imported files would not be counted towards the total progress because imported
// files are not registered with Uppy.
for (const file of this.uppy.getFiles()) {
for (const file of this.uppy.getFilesByIds(ids)) {
this.uppy.emit('postprocess-progress', file, {
mode: 'determinate',
value: details.progress_combined / 100,
Expand Down Expand Up @@ -816,7 +817,7 @@ export default class Transloadit<
this.uppy.emit('preprocess-complete', file)
})
this.#createAssemblyWatcher(assembly.status.assembly_id)
this.#connectAssembly(assembly)
this.#connectAssembly(assembly, fileIDs)
} catch (err) {
fileIDs.forEach((fileID) => {
const file = this.uppy.getFile(fileID)
Expand Down

0 comments on commit 20291e1

Please sign in to comment.