Several torrents per filesystem (#38)
Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
This commit is contained in:
parent
ed8bd64017
commit
2a38efbb03
8 changed files with 43 additions and 46 deletions
|
@ -24,7 +24,7 @@ func NewHandler(fuseAllowOther bool) *Handler {
|
|||
}
|
||||
}
|
||||
|
||||
func (s *Handler) MountAll(fss map[string][]fs.Filesystem, ef config.EventFunc) error {
|
||||
func (s *Handler) MountAll(fss map[string]fs.Filesystem, ef config.EventFunc) error {
|
||||
for p, fss := range fss {
|
||||
folder := p
|
||||
// On windows, the folder must don't exist
|
||||
|
|
|
@ -17,9 +17,9 @@ type FS struct {
|
|||
fh *fileHandler
|
||||
}
|
||||
|
||||
func NewFS(fss []fs.Filesystem) fuse.FileSystemInterface {
|
||||
func NewFS(fs fs.Filesystem) fuse.FileSystemInterface {
|
||||
return &FS{
|
||||
fh: &fileHandler{fss: fss},
|
||||
fh: &fileHandler{fs: fs},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,7 @@ var ErrBadHolderIndex = errors.New("holder index too big")
|
|||
type fileHandler struct {
|
||||
mu sync.Mutex
|
||||
opened []fs.File
|
||||
fss []fs.Filesystem
|
||||
fs fs.Filesystem
|
||||
}
|
||||
|
||||
func (fh *fileHandler) GetFile(path string, fhi uint64) (fs.File, error) {
|
||||
|
@ -163,14 +163,12 @@ func (fh *fileHandler) ListDir(path string) ([]string, error) {
|
|||
defer fh.mu.Unlock()
|
||||
|
||||
var out []string
|
||||
for _, ifs := range fh.fss {
|
||||
files, err := ifs.ReadDir(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for p := range files {
|
||||
out = append(out, p)
|
||||
}
|
||||
files, err := fh.fs.ReadDir(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for p := range files {
|
||||
out = append(out, p)
|
||||
}
|
||||
|
||||
return out, nil
|
||||
|
@ -233,18 +231,13 @@ func (fh *fileHandler) Remove(fhi uint64) error {
|
|||
}
|
||||
|
||||
func (fh *fileHandler) lookupFile(path string) (fs.File, error) {
|
||||
for _, f := range fh.fss {
|
||||
file, err := f.Open(path)
|
||||
if err == os.ErrNotExist {
|
||||
continue
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
file, err := fh.fs.Open(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if file != nil {
|
||||
return file, nil
|
||||
}
|
||||
if file != nil {
|
||||
return file, nil
|
||||
}
|
||||
|
||||
return nil, os.ErrNotExist
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue