Zfs fixes
This commit is contained in:
@@ -8,7 +8,6 @@ import (
|
||||
"bazil.org/fuse/fs"
|
||||
"github.com/debridmediamanager.com/zurg/internal/config"
|
||||
"github.com/debridmediamanager.com/zurg/internal/torrent"
|
||||
"github.com/debridmediamanager.com/zurg/pkg/chunk"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
@@ -18,11 +17,10 @@ type FS struct {
|
||||
umask os.FileMode
|
||||
directIO bool
|
||||
lock sync.RWMutex
|
||||
c config.ConfigInterface
|
||||
t *torrent.TorrentManager
|
||||
config config.ConfigInterface
|
||||
tMgr *torrent.TorrentManager
|
||||
log *zap.SugaredLogger
|
||||
initTime time.Time
|
||||
chunk *chunk.Manager
|
||||
}
|
||||
|
||||
// Root returns the root path
|
||||
|
||||
@@ -8,15 +8,13 @@ import (
|
||||
"bazil.org/fuse/fs"
|
||||
"github.com/debridmediamanager.com/zurg/internal/config"
|
||||
"github.com/debridmediamanager.com/zurg/internal/torrent"
|
||||
"github.com/debridmediamanager.com/zurg/pkg/chunk"
|
||||
"github.com/debridmediamanager.com/zurg/pkg/logutil"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func Mount(mountpoint string, cfg config.ConfigInterface, tMgr *torrent.TorrentManager, cMgr *chunk.Manager) error {
|
||||
rlog := logutil.NewLogger()
|
||||
log := rlog.Named("zfs")
|
||||
func Mount(mountpoint string, cfg config.ConfigInterface, tMgr *torrent.TorrentManager) error {
|
||||
log := logutil.NewLogger().Named("zfs")
|
||||
|
||||
options := []fuse.MountOption{
|
||||
fuse.AllowOther(),
|
||||
@@ -37,11 +35,10 @@ func Mount(mountpoint string, cfg config.ConfigInterface, tMgr *torrent.TorrentM
|
||||
uid: uint32(unix.Geteuid()),
|
||||
gid: uint32(unix.Getegid()),
|
||||
umask: os.FileMode(0),
|
||||
c: cfg,
|
||||
t: tMgr,
|
||||
config: cfg,
|
||||
tMgr: tMgr,
|
||||
log: log,
|
||||
initTime: time.Now(),
|
||||
chunk: cMgr,
|
||||
}
|
||||
|
||||
if err := srv.Serve(filesys); err != nil {
|
||||
|
||||
@@ -58,14 +58,14 @@ func (o Object) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
|
||||
dirs := []fuse.Dirent{}
|
||||
switch o.objType {
|
||||
case ROOT:
|
||||
for _, directory := range o.fs.c.GetDirectories() {
|
||||
for _, directory := range o.fs.config.GetDirectories() {
|
||||
dirs = append(dirs, fuse.Dirent{
|
||||
Name: directory,
|
||||
Type: fuse.DT_Dir,
|
||||
})
|
||||
}
|
||||
case DIRECTORY:
|
||||
for el := o.fs.t.TorrentMap.Front(); el != nil; el = el.Next() {
|
||||
for el := o.fs.tMgr.TorrentMap.Front(); el != nil; el = el.Next() {
|
||||
torrent := el.Value
|
||||
if torrent.InProgress {
|
||||
continue
|
||||
@@ -76,7 +76,7 @@ func (o Object) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
|
||||
})
|
||||
}
|
||||
case TORRENT:
|
||||
torrent, _ := o.fs.t.TorrentMap.Get(o.name)
|
||||
torrent, _ := o.fs.tMgr.TorrentMap.Get(o.name)
|
||||
if torrent == nil || torrent.InProgress {
|
||||
return nil, syscall.ENOENT
|
||||
}
|
||||
@@ -100,7 +100,7 @@ func (o Object) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
|
||||
func (o Object) Lookup(ctx context.Context, name string) (fs.Node, error) {
|
||||
switch o.objType {
|
||||
case ROOT:
|
||||
for _, directory := range o.fs.c.GetDirectories() {
|
||||
for _, directory := range o.fs.config.GetDirectories() {
|
||||
if directory == name {
|
||||
return Object{
|
||||
fs: o.fs,
|
||||
@@ -112,7 +112,7 @@ func (o Object) Lookup(ctx context.Context, name string) (fs.Node, error) {
|
||||
}
|
||||
}
|
||||
case DIRECTORY:
|
||||
torrent, _ := o.fs.t.TorrentMap.Get(name)
|
||||
torrent, _ := o.fs.tMgr.TorrentMap.Get(name)
|
||||
if torrent == nil {
|
||||
return nil, syscall.ENOENT
|
||||
}
|
||||
@@ -125,7 +125,7 @@ func (o Object) Lookup(ctx context.Context, name string) (fs.Node, error) {
|
||||
}, nil
|
||||
|
||||
case TORRENT:
|
||||
torrent, _ := o.fs.t.TorrentMap.Get(o.name)
|
||||
torrent, _ := o.fs.tMgr.TorrentMap.Get(o.name)
|
||||
if torrent == nil {
|
||||
return nil, syscall.ENOENT
|
||||
}
|
||||
@@ -155,7 +155,7 @@ func (o Object) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.Open
|
||||
|
||||
// Read reads some bytes or the whole file
|
||||
func (o Object) Read(ctx context.Context, req *fuse.ReadRequest, resp *fuse.ReadResponse) error {
|
||||
reader := universal.GetFileReader(o.torrent, o.file, req.Offset, int(req.Size), o.fs.t, o.fs.c, o.fs.log)
|
||||
reader := universal.GetFileReader(o.torrent, o.file, req.Offset, int(req.Size), o.fs.tMgr, o.fs.config, o.fs.log)
|
||||
if reader == nil {
|
||||
return syscall.EIO
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user