Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
  • Loading branch information
Wwwsylvia committed Jan 17, 2025
1 parent 737f7e9 commit 16cc1d8
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions internal/fs/tarfs/tarfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ func (tfs *TarFS) getEntry(operation string, path string) (*entry, error) {
if !fs.ValidPath(path) {
return nil, &fs.PathError{Op: operation, Path: path, Err: fs.ErrInvalid}
}
key := getEntryKey(path)
entry, ok := tfs.entries[key]
entry, ok := tfs.entries[path]
if !ok {
return nil, &fs.PathError{Op: operation, Path: path, Err: fs.ErrNotExist}
}
Expand Down Expand Up @@ -146,20 +145,15 @@ func (tfs *TarFS) indexEntries() error {
return err
}

key := getEntryKey(header.Name)
tfs.entries[key] = &entry{
cleanPath := path.Clean(header.Name)
tfs.entries[cleanPath] = &entry{
header: header,
pos: pos - blockSize,
}
}
return nil
}

// getEntryKey cleans the name and returns a key for the entry.
func getEntryKey(name string) string {
return path.Clean(name)
}

// entryFile represents an entryFile in a tar archive and implements `fs.File`.
type entryFile struct {
io.Reader
Expand Down

0 comments on commit 16cc1d8

Please sign in to comment.