fixed directory decryption
This commit is contained in:
parent
616aca97f9
commit
4e1d5b36b2
2 changed files with 33 additions and 10 deletions
|
|
@ -16,9 +16,18 @@ type file struct {
|
|||
nonce [NonceSize]byte
|
||||
offset int64
|
||||
name string
|
||||
dir bool
|
||||
}
|
||||
|
||||
func newFile(key []byte, name string, fs *FS, f provider.File) (ef provider.File, err error) {
|
||||
func newFile(key []byte, name string, fs *FS, f provider.File, dir bool) (ef provider.File, err error) {
|
||||
if dir {
|
||||
return &file{
|
||||
File: f,
|
||||
fs: fs,
|
||||
name: name,
|
||||
dir: dir,
|
||||
}, nil
|
||||
}
|
||||
nonce, err := initNonce(f)
|
||||
if err != nil {
|
||||
return
|
||||
|
|
@ -68,6 +77,9 @@ func (s stat) Name() string {
|
|||
}
|
||||
|
||||
func (f *file) Close() error {
|
||||
if f.dir {
|
||||
return f.File.Close()
|
||||
}
|
||||
e1 := f.w.Close()
|
||||
e2 := f.File.Close()
|
||||
if e1 != nil {
|
||||
|
|
@ -155,7 +167,11 @@ func (f *file) Readdir(n int) ([]fs.FileInfo, error) {
|
|||
}
|
||||
fio := make([]fs.FileInfo, len(fis))
|
||||
for i, fi := range fis {
|
||||
fio[i] = dir{FileInfo: fi, name: f.fs.decPath(fi.Name())}
|
||||
name, err := f.fs.decPath(fi.Name())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fio[i] = dir{FileInfo: fi, name: name}
|
||||
}
|
||||
return fio, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue