Skip to content

Commit

Permalink
fix: renterd uploads new intermediate directories
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfreska committed Aug 12, 2024
1 parent 6ad3f2f commit 904b3d2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/sweet-fans-suffer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'renterd': minor
---

The file explorer now shows new directories right away when uploading nested files.
24 changes: 24 additions & 0 deletions apps/renterd/contexts/filesManager/dataset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,30 @@ export function useDataset({ id, objects }: Props) {
type: isDirectory(key) ? 'directory' : 'file',
}
})
// Get intermediate directories that may not exist yet and add them
// so that they show up before the files are fully uploaded.
for (const upload of uploadsList) {
if (upload.path.startsWith(activeDirectoryPath)) {
const afterPath = upload.path.slice(activeDirectoryPath.length)
const parts = afterPath.split('/')
const dirName = parts[0]
if (parts.length > 1) {
const intermediateDir = join(activeDirectoryPath, dirName) + '/'
dataMap[intermediateDir] = {
id: intermediateDir,
path: intermediateDir,
bucket: activeBucket,
size: 0,
health: 0,
name: dirName + '/',
onClick: () => {
setActiveDirectory((p) => p.concat(dirName))
},
type: 'directory',
}
}
}
}
uploadsList
.filter(({ path, name }) => path === join(activeDirectoryPath, name))
.filter(({ path }) =>
Expand Down

0 comments on commit 904b3d2

Please sign in to comment.