File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -640,7 +640,7 @@ func (f *ArchiveFS) ReadDir(name string) ([]fs.DirEntry, error) {
640
640
return & fs.PathError {Op : "readdir" , Path : name , Err : errors .New ("not a directory" )}
641
641
}
642
642
643
- // index this file info for quick access
643
+ // index this file info for quick access (overwrite any implicit one that may have been created)
644
644
f .contents [file .NameInArchive ] = file
645
645
646
646
// amortize the DirEntry list per directory, and prefer the real entry's DirEntry over an implicit/fake
@@ -682,6 +682,16 @@ func (f *ArchiveFS) ReadDir(name string) ([]fs.DirEntry, error) {
682
682
if ! found {
683
683
f .dirs [dir ] = slices .Insert (f .dirs [dir ], idx , dirInfo )
684
684
}
685
+
686
+ // we also need to treat implicit directories as real ones for the sake of FS traversal,
687
+ // so be sure to add to our amortization cache an implicit FileInfo for each parent dir
688
+ // that doesn't have an explicit entry in the archive; this will get overwritten with
689
+ // a real one if we encounter it, but without filling in the implied directory tree,
690
+ // FS walks *after the first one* (the first one doesn't use the contents cache) will
691
+ // omit all implicit directories from their walk, missing many contents!
692
+ if _ , ok := f .contents [dir ]; ! ok {
693
+ f .contents [dir ] = dirInfo .(fs.FileInfo )
694
+ }
685
695
}
686
696
687
697
return nil
You can’t perform that action at this time.
0 commit comments