1
mirror of https://github.com/rclone/rclone synced 2024-12-22 13:03:02 +01:00

vfs: Add go-billy dependency and make sure vfs.Handle implements billy.File

billy defines a common file system interface that is used in multiple go packages.
vfs.Handle implements billy.File mostly, only two methods needed to be added to
make it compliant.

An interface check is added as well.

This is a preliminary work for adding serve nfs command.
This commit is contained in:
Saleh Dindar 2023-10-04 10:25:57 -07:00 committed by Nick Craig-Wood
parent 7801b160f2
commit 25f59b2918
5 changed files with 32 additions and 5 deletions

1
go.mod
View File

@ -26,6 +26,7 @@ require (
github.com/gabriel-vasile/mimetype v1.4.2 github.com/gabriel-vasile/mimetype v1.4.2
github.com/gdamore/tcell/v2 v2.6.0 github.com/gdamore/tcell/v2 v2.6.0
github.com/go-chi/chi/v5 v5.0.10 github.com/go-chi/chi/v5 v5.0.10
github.com/go-git/go-billy/v5 v5.4.1
github.com/google/uuid v1.3.1 github.com/google/uuid v1.3.1
github.com/hanwen/go-fuse/v2 v2.3.0 github.com/hanwen/go-fuse/v2 v2.3.0
github.com/henrybear327/Proton-API-Bridge v0.0.0-20230908065933-5bfa15b567db github.com/henrybear327/Proton-API-Bridge v0.0.0-20230908065933-5bfa15b567db

2
go.sum
View File

@ -187,6 +187,8 @@ github.com/glycerine/go-unsnap-stream v0.0.0-20180323001048-9f0cb55181dd/go.mod
github.com/glycerine/goconvey v0.0.0-20180728074245-46e3a41ad493/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24= github.com/glycerine/goconvey v0.0.0-20180728074245-46e3a41ad493/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24=
github.com/go-chi/chi/v5 v5.0.10 h1:rLz5avzKpjqxrYwXNfmjkrYYXOyLJd37pz53UFHC6vk= github.com/go-chi/chi/v5 v5.0.10 h1:rLz5avzKpjqxrYwXNfmjkrYYXOyLJd37pz53UFHC6vk=
github.com/go-chi/chi/v5 v5.0.10/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= github.com/go-chi/chi/v5 v5.0.10/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
github.com/go-git/go-billy/v5 v5.4.1 h1:Uwp5tDRkPr+l/TnbHOQzp+tmJfLceOlbVucgpTz8ix4=
github.com/go-git/go-billy/v5 v5.4.1/go.mod h1:vjbugF6Fz7JIflbVpl1hJsGjSHNltrSw45YK/ukIvQg=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=

View File

@ -30,6 +30,16 @@ type RWFileHandle struct {
writeCalled bool // if any Write() methods have been called writeCalled bool // if any Write() methods have been called
} }
// Lock performs Unix locking, not supported
func (fh *RWFileHandle) Lock() error {
return os.ErrInvalid
}
// Unlock performs Unix unlocking, not supported
func (fh *RWFileHandle) Unlock() error {
return os.ErrInvalid
}
func newRWFileHandle(d *Dir, f *File, flags int) (fh *RWFileHandle, err error) { func newRWFileHandle(d *Dir, f *File, flags int) (fh *RWFileHandle, err error) {
defer log.Trace(f.Path(), "")("err=%v", &err) defer log.Trace(f.Path(), "")("err=%v", &err)
// get an item to represent this from the cache // get an item to represent this from the cache

View File

@ -32,6 +32,7 @@ import (
"sync/atomic" "sync/atomic"
"time" "time"
"github.com/go-git/go-billy/v5"
"github.com/rclone/rclone/fs" "github.com/rclone/rclone/fs"
"github.com/rclone/rclone/fs/cache" "github.com/rclone/rclone/fs/cache"
"github.com/rclone/rclone/fs/log" "github.com/rclone/rclone/fs/log"
@ -119,6 +120,8 @@ type Handle interface {
Release() error Release() error
Node() Node Node() Node
// Size() int64 // Size() int64
Lock() error
Unlock() error
} }
// baseHandle implements all the missing methods // baseHandle implements all the missing methods
@ -144,6 +147,8 @@ func (h baseHandle) WriteString(s string) (n int, err error) { retu
func (h baseHandle) Flush() (err error) { return ENOSYS } func (h baseHandle) Flush() (err error) { return ENOSYS }
func (h baseHandle) Release() (err error) { return ENOSYS } func (h baseHandle) Release() (err error) { return ENOSYS }
func (h baseHandle) Node() Node { return nil } func (h baseHandle) Node() Node { return nil }
func (h baseHandle) Unlock() error { return os.ErrInvalid }
func (h baseHandle) Lock() error { return os.ErrInvalid }
//func (h baseHandle) Size() int64 { return 0 } //func (h baseHandle) Size() int64 { return 0 }
@ -154,6 +159,7 @@ var (
_ Handle = (*ReadFileHandle)(nil) _ Handle = (*ReadFileHandle)(nil)
_ Handle = (*WriteFileHandle)(nil) _ Handle = (*WriteFileHandle)(nil)
_ Handle = (*DirHandle)(nil) _ Handle = (*DirHandle)(nil)
_ billy.File = (Handle)(nil)
) )
// VFS represents the top level filing system // VFS represents the top level filing system

View File

@ -48,6 +48,14 @@ func (f realOsFile) Node() vfs.Node {
return nil return nil
} }
func (f realOsFile) Lock() error {
return os.ErrInvalid
}
func (f realOsFile) Unlock() error {
return os.ErrInvalid
}
// Chtimes // Chtimes
func (r realOs) Chtimes(name string, atime time.Time, mtime time.Time) error { func (r realOs) Chtimes(name string, atime time.Time, mtime time.Time) error {
return os.Chtimes(name, atime, mtime) return os.Chtimes(name, atime, mtime)