Documentation ¶
Overview ¶
Package basefs implements a base filesystem caching entries
Index ¶
- Variables
- type BaseFS
- func (fs *BaseFS) CheckForChanges()
- func (fs *BaseFS) CreateFile(ctx context.Context, op *fuseops.CreateFileOp) (err error)
- func (fs *BaseFS) FlushFile(ctx context.Context, op *fuseops.FlushFileOp) (err error)
- func (fs *BaseFS) ForgetInode(ctx context.Context, op *fuseops.ForgetInodeOp) (err error)
- func (fs *BaseFS) GetInodeAttributes(ctx context.Context, op *fuseops.GetInodeAttributesOp) (err error)
- func (fs *BaseFS) GetXAttr(ctx context.Context, op *fuseops.GetXattrOp) (err error)
- func (fs *BaseFS) LookUpInode(ctx context.Context, op *fuseops.LookUpInodeOp) (err error)
- func (fs *BaseFS) MkDir(ctx context.Context, op *fuseops.MkDirOp) (err error)
- func (fs *BaseFS) OpenDir(ctx context.Context, op *fuseops.OpenDirOp) (err error)
- func (fs *BaseFS) OpenFile(ctx context.Context, op *fuseops.OpenFileOp) (err error)
- func (fs *BaseFS) ReadDir(ctx context.Context, op *fuseops.ReadDirOp) (err error)
- func (fs *BaseFS) ReadFile(ctx context.Context, op *fuseops.ReadFileOp) (err error)
- func (fs *BaseFS) Refresh()
- func (fs *BaseFS) ReleaseDirHandle(ctx context.Context, op *fuseops.ReleaseDirHandleOp) (err error)
- func (fs *BaseFS) ReleaseFileHandle(ctx context.Context, op *fuseops.ReleaseFileHandleOp) (err error)
- func (fs *BaseFS) Rename(ctx context.Context, op *fuseops.RenameOp) (err error)
- func (fs *BaseFS) RmDir(ctx context.Context, op *fuseops.RmDirOp) (err error)
- func (fs *BaseFS) SetInodeAttributes(ctx context.Context, op *fuseops.SetInodeAttributesOp) (err error)
- func (fs *BaseFS) Start()
- func (fs *BaseFS) StatFS(ctx context.Context, op *fuseops.StatFSOp) (err error)
- func (fs *BaseFS) Unlink(ctx context.Context, op *fuseops.UnlinkOp) (err error)
- func (fs *BaseFS) WriteFile(ctx context.Context, op *fuseops.WriteFileOp) (err error)
- type Change
- type File
- type FileContainer
- func (fc *FileContainer) Count() int
- func (fc *FileContainer) CreateFile(parentFile *FileEntry, name string, isDir bool) (*FileEntry, error)
- func (fc *FileContainer) DeleteFile(entry *FileEntry) error
- func (fc *FileContainer) FileEntry(file *File, inodeOps ...fuseops.InodeID) *FileEntry
- func (fc *FileContainer) FindByID(id string) *FileEntry
- func (fc *FileContainer) FindByInode(inode fuseops.InodeID) *FileEntry
- func (fc *FileContainer) ListByParent(parent *FileEntry) []*FileEntry
- func (fc *FileContainer) Lookup(parent *FileEntry, name string) *FileEntry
- func (fc *FileContainer) LookupByID(parentID string, name string) *FileEntry
- func (fc *FileContainer) RemoveEntry(entry *FileEntry)
- func (fc *FileContainer) SetEntry(inode fuseops.InodeID, entry *FileEntry)
- type FileEntry
- func (fe *FileEntry) Cache(fc *FileContainer) *FileWrapper
- func (fe *FileEntry) ClearCache() (err error)
- func (fe *FileEntry) HasParent(parent *FileEntry) bool
- func (fe *FileEntry) HasParentID(parentID string) bool
- func (fe *FileEntry) IsDir() bool
- func (fe *FileEntry) SetFile(file *File, uid, gid uint32)
- func (fe *FileEntry) Sync(fc *FileContainer) (err error)
- func (fe *FileEntry) Truncate() (err error)
- type FileWrapper
- type Service
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotImplemented basic Not implemented error ErrNotImplemented = errors.New("Not implemented") // ErrPermission permission denied error ErrPermission = errors.New("Permission denied") )
Functions ¶
This section is empty.
Types ¶
type BaseFS ¶
type BaseFS struct { fuseutil.NotImplementedFileSystem // Defaults Config *core.Config //core *core.Core // Core Config instead? Root *FileContainer Service Service // contains filtered or unexported fields }
BaseFS data
func (*BaseFS) CreateFile ¶
CreateFile creates empty file in google Drive and returns its ID and attributes, only allows file creation on 'My Drive' Cloud SPECIFIC
func (*BaseFS) FlushFile ¶
FlushFile just returns no error, maybe upload should be handled here COMMON
func (*BaseFS) ForgetInode ¶
ForgetInode allows to forgetInode COMMON
func (*BaseFS) GetInodeAttributes ¶
func (fs *BaseFS) GetInodeAttributes(ctx context.Context, op *fuseops.GetInodeAttributesOp) (err error)
GetInodeAttributes return attributes COMMON
func (*BaseFS) LookUpInode ¶
LookUpInode based on Parent and Name we return a self cached inode Cloud be COMMON but has specific ID
func (*BaseFS) OpenFile ¶
OpenFile creates a temporary handle to be handled on read or write XXX: Check what to do if the tempfile exists locally
func (*BaseFS) ReadFile ¶
ReadFile if the first time we download the google drive file into a local temporary file COMMON but specific in cache
func (*BaseFS) ReleaseDirHandle ¶
ReleaseDirHandle deletes file handle entry COMMON
func (*BaseFS) ReleaseFileHandle ¶
func (fs *BaseFS) ReleaseFileHandle(ctx context.Context, op *fuseops.ReleaseFileHandleOp) (err error)
ReleaseFileHandle closes and deletes any temporary files, upload in case if changed locally COMMON
func (*BaseFS) SetInodeAttributes ¶
func (fs *BaseFS) SetInodeAttributes(ctx context.Context, op *fuseops.SetInodeAttributesOp) (err error)
SetInodeAttributes Not sure what attributes gdrive support we just leave this blank for now SPECIFIC code
type File ¶
type File struct { ID string Name string Size uint64 CreatedTime time.Time ModifiedTime time.Time AccessedTime time.Time Mode os.FileMode Parents []string Data interface{} // Any thing }
File entry structure all basefs based services must use these
type FileContainer ¶
type FileContainer struct {
// contains filtered or unexported fields
}
FileContainer will hold file entries
func NewFileContainer ¶
func NewFileContainer(fs *BaseFS) *FileContainer
NewFileContainer creates and initialize a FileContainer
func (*FileContainer) Count ¶
func (fc *FileContainer) Count() int
Count the total number of fileentries
func (*FileContainer) CreateFile ¶
func (fc *FileContainer) CreateFile(parentFile *FileEntry, name string, isDir bool) (*FileEntry, error)
CreateFile tell service to create a file
func (*FileContainer) DeleteFile ¶
func (fc *FileContainer) DeleteFile(entry *FileEntry) error
DeleteFile tell service to delete a file
func (*FileContainer) FileEntry ¶
func (fc *FileContainer) FileEntry(file *File, inodeOps ...fuseops.InodeID) *FileEntry
FileEntry Create or Update a FileEntry by inode, inode is an optional argument
func (*FileContainer) FindByID ¶
func (fc *FileContainer) FindByID(id string) *FileEntry
FindByID retrives by ID
func (*FileContainer) FindByInode ¶
func (fc *FileContainer) FindByInode(inode fuseops.InodeID) *FileEntry
FindByInode retrieves a file entry by inode
func (*FileContainer) ListByParent ¶
func (fc *FileContainer) ListByParent(parent *FileEntry) []*FileEntry
ListByParent entries from parent
func (*FileContainer) Lookup ¶
func (fc *FileContainer) Lookup(parent *FileEntry, name string) *FileEntry
Lookup retrives a FileEntry from a parent(folder) with name
func (*FileContainer) LookupByID ¶
func (fc *FileContainer) LookupByID(parentID string, name string) *FileEntry
LookupByID lookup by remote ID
func (*FileContainer) RemoveEntry ¶
func (fc *FileContainer) RemoveEntry(entry *FileEntry)
RemoveEntry remove file entry
type FileEntry ¶
type FileEntry struct { sync.Mutex Inode fuseops.InodeID // Inode File *File // Remote file information Name string // local name Attr fuseops.InodeAttributes // Cached attributes // contains filtered or unexported fields }
FileEntry entry to handle files
func (*FileEntry) Cache ¶
func (fe *FileEntry) Cache(fc *FileContainer) *FileWrapper
Cache download cloud file to a temporary local file or return already created file
func (*FileEntry) ClearCache ¶
ClearCache remove local file XXX: move this to FileEntry
func (*FileEntry) HasParentID ¶
HasParentID check parent by cloud ID
func (*FileEntry) Sync ¶
func (fe *FileEntry) Sync(fc *FileContainer) (err error)
Sync will flush, upload file and update local entry
type FileWrapper ¶
FileWrapper helper to prevent http.Post to close my files
func (*FileWrapper) RealClose ¶
func (f *FileWrapper) RealClose() error
RealClose to be called internally to close the file
type Service ¶
type Service interface { Changes() ([]*Change, error) ListAll() ([]*File, error) Create(parent *File, name string, isDir bool) (*File, error) //Truncate(file *File) (*File, error) Upload(reader io.Reader, file *File) (*File, error) DownloadTo(w io.Writer, file *File) error Move(file *File, newParent *File, name string) (*File, error) Delete(file *File) error //-- implementing StatFS(*fuseops.StatFSOp) error }
Service interface