Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Commit

Permalink
trim NameInArchive to make file behavior in line with stdlib file system
Browse files Browse the repository at this point in the history
  • Loading branch information
WeidiDeng committed Oct 15, 2022
1 parent 564c188 commit ed7c8b2
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ func (f ArchiveFS) Open(name string) (fs.File, error) {
)
// collect them all or stop at exact file match, note we don't stop at folder match
handler := func(_ context.Context, file File) error {
file.NameInArchive = strings.Trim(file.NameInArchive, "/")
files = append(files, file)
if file.NameInArchive == name && !file.IsDir() {
found = true
Expand Down Expand Up @@ -501,6 +502,7 @@ func (f ArchiveFS) Stat(name string) (fs.FileInfo, error) {
found bool
)
handler := func(_ context.Context, file File) error {
file.NameInArchive = strings.Trim(file.NameInArchive, "/")
files = append(files, file)
if file.NameInArchive == name {
found = true
Expand Down Expand Up @@ -557,6 +559,7 @@ func (f ArchiveFS) ReadDir(name string) ([]fs.DirEntry, error) {
foundFile bool
)
handler := func(_ context.Context, file File) error {
file.NameInArchive = strings.Trim(file.NameInArchive, "/")
files = append(files, file)
if file.NameInArchive == name && !file.IsDir() {
foundFile = true
Expand Down

0 comments on commit ed7c8b2

Please sign in to comment.