Skip to content

Commit

Permalink
fix calls to Stat() on vdirfs
Browse files Browse the repository at this point in the history
  • Loading branch information
MagicalTux committed Jan 16, 2020
1 parent 4784a19 commit 6dd253c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions vdirfs/dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func (d *dir) getDir(name string, create bool) (*dir, error) {
return nil, os.ErrNotExist
}
sd = &dir{
fs: d.fs,
path: path.Join(d.path, name),
children: make(map[string]*dir),
}
Expand Down
8 changes: 7 additions & 1 deletion vdirfs/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func New(fs vfs.FileSystem) (*FS, error) {
}

f.root = &dir{
path: "/",
path: "",
children: make(map[string]*dir),
fs: f,
}
Expand Down Expand Up @@ -67,10 +67,16 @@ func (f *FS) OpenFile(path string, flag int, perm os.FileMode) (vfs.File, error)
}

func (f *FS) Lstat(path string) (os.FileInfo, error) {
if d, err := f.root.getDir(path, false); err == nil && d != nil {
return d.Stat()
}
return f.parent.Lstat(path)
}

func (f *FS) Stat(path string) (os.FileInfo, error) {
if d, err := f.root.getDir(path, false); err == nil && d != nil {
return d.Stat()
}
return f.parent.Stat(path)
}

Expand Down
5 changes: 4 additions & 1 deletion zipfs/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ func newZipMap(z *zip.Reader, addVdir bool) (vfs.FileSystem, error) {
}

for f, _ := range m.i {
res.AddPath(f)
err := res.AddPath(f)
if err != nil {
return nil, err
}
}

return res, nil
Expand Down

0 comments on commit 6dd253c

Please sign in to comment.