Skip to content

Commit

Permalink
Provide relativePath for remote files
Browse files Browse the repository at this point in the history
  • Loading branch information
dschmidt committed Jul 10, 2023
1 parent cfc6185 commit 9f111c5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/@uppy/provider-views/src/ProviderView/ProviderView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ export default class ProviderView extends View {
}
}

async recursivelyListAllFiles (path, queue, onFiles) {
let curPath = path
async recursivelyListAllFiles (requestPath, directories, queue, onFiles) {
let curPath = requestPath

while (curPath) {
const res = await this.provider.list(curPath)
Expand All @@ -303,11 +303,14 @@ export default class ProviderView extends View {
const files = res.items.filter((item) => !item.isFolder)
const folders = res.items.filter((item) => item.isFolder)

// eslint-disable-next-line
files.forEach(f => f.relativePath = `/${directories.map(d => d.name).join('/')}/${f.name}`)

onFiles(files)

// recursively queue call to self for each folder
const promises = folders.map(async (folder) => queue.add(async () => (
this.recursivelyListAllFiles(folder.requestPath, queue, onFiles)
this.recursivelyListAllFiles(folder.requestPath, [...directories, folder], queue, onFiles)
)))
await Promise.all(promises) // in case we get an error
}
Expand Down Expand Up @@ -346,7 +349,7 @@ export default class ProviderView extends View {
}
}

await this.recursivelyListAllFiles(requestPath, queue, onFiles)
await this.recursivelyListAllFiles(requestPath, [file], queue, onFiles)
await queue.onIdle()

let message
Expand Down

0 comments on commit 9f111c5

Please sign in to comment.