Skip to content

Commit

Permalink
normalizePath now always return absolute path, BasePathFs removes vol…
Browse files Browse the repository at this point in the history
…ume name from path
  • Loading branch information
nofun97 committed Sep 14, 2020
1 parent 6f053d3 commit 20b0b95
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion basepath.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ type BasePathFile struct {

func (f *BasePathFile) Name() string {
sourcename := f.File.Name()
return strings.TrimPrefix(sourcename, filepath.Clean(f.path))
sourcename = strings.TrimPrefix(sourcename, filepath.VolumeName(sourcename))
sourcename = strings.TrimPrefix(sourcename, filepath.Clean(f.path))
return sourcename
}

func NewBasePathFs(source Fs, path string) Fs {
Expand Down
2 changes: 1 addition & 1 deletion composite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ func TestUnionFileReaddirAskForTooMany(t *testing.T) {

const testFiles = 5
for i := 0; i < testFiles; i++ {
WriteFile(base, fmt.Sprintf("file%d.txt", i), []byte("afero"), 0777)
WriteFile(base, fmt.Sprintf("/file%d.txt", i), []byte("afero"), 0777)
}

ufs := &CopyOnWriteFs{base: base, layer: overlay}
Expand Down
2 changes: 1 addition & 1 deletion memmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func normalizePath(path string) (string, error) {
case FilePathSeparator:
return rootAbs, nil
default:
return path, nil
return filepath.Abs(path)
}
}

Expand Down

0 comments on commit 20b0b95

Please sign in to comment.