Documentation ¶
Index ¶
- func Octal(i uint32) string
- func UnmountHandler(signal <-chan os.Signal, server *fuse.Server)
- type FileSystemInfo
- type Filesystem
- func (f *Filesystem) Create(cancel <-chan struct{}, in *fuse.CreateIn, name string, out *fuse.CreateOut) fuse.Status
- func (f *Filesystem) DeleteID(id string)
- func (f *Filesystem) DeletePath(key string)
- func (f *Filesystem) DeltaLoop(interval time.Duration)
- func (f *Filesystem) Flush(cancel <-chan struct{}, in *fuse.FlushIn) fuse.Status
- func (f *Filesystem) Fsync(cancel <-chan struct{}, in *fuse.FsyncIn) fuse.Status
- func (f *Filesystem) GetAttr(cancel <-chan struct{}, in *fuse.GetAttrIn, out *fuse.AttrOut) fuse.Status
- func (f *Filesystem) GetChild(id string, name string, auth *graph.Auth) (*Inode, error)
- func (f *Filesystem) GetChildrenID(id string, auth *graph.Auth) (map[string]*Inode, error)
- func (f *Filesystem) GetChildrenPath(path string, auth *graph.Auth) (map[string]*Inode, error)
- func (f *Filesystem) GetID(id string) *Inode
- func (f *Filesystem) GetNodeID(nodeID uint64) *Inode
- func (f *Filesystem) GetPath(path string, auth *graph.Auth) (*Inode, error)
- func (f *Filesystem) InsertChild(parentID string, child *Inode) uint64
- func (f *Filesystem) InsertID(id string, inode *Inode) uint64
- func (f *Filesystem) InsertNodeID(inode *Inode) uint64
- func (f *Filesystem) InsertPath(key string, auth *graph.Auth, inode *Inode) (uint64, error)
- func (f *Filesystem) IsOffline() bool
- func (f *Filesystem) Lookup(cancel <-chan struct{}, in *fuse.InHeader, name string, out *fuse.EntryOut) fuse.Status
- func (f *Filesystem) Mkdir(cancel <-chan struct{}, in *fuse.MkdirIn, name string, out *fuse.EntryOut) fuse.Status
- func (f *Filesystem) Mknod(cancel <-chan struct{}, in *fuse.MknodIn, name string, out *fuse.EntryOut) fuse.Status
- func (f *Filesystem) MoveID(oldID string, newID string) error
- func (f *Filesystem) MovePath(oldParent, newParent, oldName, newName string, auth *graph.Auth) error
- func (f *Filesystem) Open(cancel <-chan struct{}, in *fuse.OpenIn, out *fuse.OpenOut) fuse.Status
- func (f *Filesystem) OpenDir(cancel <-chan struct{}, in *fuse.OpenIn, out *fuse.OpenOut) fuse.Status
- func (f *Filesystem) Read(cancel <-chan struct{}, in *fuse.ReadIn, buf []byte) (fuse.ReadResult, fuse.Status)
- func (f *Filesystem) ReadDir(cancel <-chan struct{}, in *fuse.ReadIn, out *fuse.DirEntryList) fuse.Status
- func (f *Filesystem) ReadDirPlus(cancel <-chan struct{}, in *fuse.ReadIn, out *fuse.DirEntryList) fuse.Status
- func (f *Filesystem) ReleaseDir(in *fuse.ReleaseIn)
- func (f *Filesystem) Rename(cancel <-chan struct{}, in *fuse.RenameIn, name string, newName string) fuse.Status
- func (f *Filesystem) Rmdir(cancel <-chan struct{}, in *fuse.InHeader, name string) fuse.Status
- func (f *Filesystem) SerializeAll()
- func (f *Filesystem) SetAttr(cancel <-chan struct{}, in *fuse.SetAttrIn, out *fuse.AttrOut) fuse.Status
- func (f *Filesystem) StatFs(cancel <-chan struct{}, in *fuse.InHeader, out *fuse.StatfsOut) fuse.Status
- func (f *Filesystem) TranslateID(nodeID uint64) string
- func (f *Filesystem) Unlink(cancel <-chan struct{}, in *fuse.InHeader, name string) fuse.Status
- func (f *Filesystem) Write(cancel <-chan struct{}, in *fuse.WriteIn, data []byte) (uint32, fuse.Status)
- type Inode
- func (i *Inode) AsJSON() []byte
- func (i *Inode) HasChanges() bool
- func (i *Inode) HasChildren() bool
- func (i *Inode) ID() string
- func (i *Inode) IsDir() bool
- func (i *Inode) ModTime() uint64
- func (i *Inode) Mode() uint32
- func (i *Inode) NLink() uint32
- func (i *Inode) Name() string
- func (i *Inode) NodeID() uint64
- func (i *Inode) ParentID() string
- func (i *Inode) Path() string
- func (i *Inode) SetName(name string)
- func (i *Inode) SetNodeID(id uint64) uint64
- func (i *Inode) Size() uint64
- func (i *Inode) String() string
- type LoopbackCache
- func (l *LoopbackCache) Close(id string)
- func (l *LoopbackCache) Delete(id string) error
- func (l *LoopbackCache) Get(id string) []byte
- func (l *LoopbackCache) HasContent(id string) bool
- func (l *LoopbackCache) Insert(id string, content []byte) error
- func (l *LoopbackCache) InsertStream(id string, reader io.Reader) (int64, error)
- func (l *LoopbackCache) IsOpen(id string) bool
- func (l *LoopbackCache) Move(oldID string, newID string) error
- func (l *LoopbackCache) Open(id string) (*os.File, error)
- type SerializeableInode
- type UploadManager
- type UploadSession
- type UploadSessionPost
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type FileSystemInfo ¶
type FileSystemInfo struct {
LastModifiedDateTime time.Time `json:"lastModifiedDateTime,omitempty"`
}
FileSystemInfo carries the filesystem metadata like Mtime/Atime
type Filesystem ¶ added in v0.12.0
type Filesystem struct { fuse.RawFileSystem sync.RWMutex // contains filtered or unexported fields }
Filesystem is the actual FUSE filesystem and uses the go analogy of the "low-level" FUSE API here: https://github.com/libfuse/libfuse/blob/master/include/fuse_lowlevel.h
func NewFilesystem ¶ added in v0.12.0
func NewFilesystem(auth *graph.Auth, cacheDir string) *Filesystem
NewFilesystem creates a new filesystem
func (*Filesystem) Create ¶ added in v0.12.0
func (f *Filesystem) Create(cancel <-chan struct{}, in *fuse.CreateIn, name string, out *fuse.CreateOut) fuse.Status
Create creates a regular file and opens it. The server doesn't have this yet.
func (*Filesystem) DeleteID ¶ added in v0.12.0
func (f *Filesystem) DeleteID(id string)
DeleteID deletes an item from the cache, and removes it from its parent. Must be called before InsertID if being used to rename/move an item.
func (*Filesystem) DeletePath ¶ added in v0.12.0
func (f *Filesystem) DeletePath(key string)
DeletePath an item from the cache by path. Must be called before Insert if being used to move/rename an item.
func (*Filesystem) DeltaLoop ¶ added in v0.12.0
func (f *Filesystem) DeltaLoop(interval time.Duration)
DeltaLoop creates a new thread to poll the server for changes and should be called as a goroutine
func (*Filesystem) Flush ¶ added in v0.12.0
func (f *Filesystem) Flush(cancel <-chan struct{}, in *fuse.FlushIn) fuse.Status
Flush is called when a file descriptor is closed. Uses Fsync() to perform file uploads. (Release not implemented because all cleanup is already done here).
func (*Filesystem) Fsync ¶ added in v0.12.0
func (f *Filesystem) Fsync(cancel <-chan struct{}, in *fuse.FsyncIn) fuse.Status
Fsync is a signal to ensure writes to the Inode are flushed to stable storage. This method is used to trigger uploads of file content.
func (*Filesystem) GetAttr ¶ added in v0.12.0
func (f *Filesystem) GetAttr(cancel <-chan struct{}, in *fuse.GetAttrIn, out *fuse.AttrOut) fuse.Status
Getattr returns a the Inode as a UNIX stat. Holds the read mutex for all of the "metadata fetch" operations.
func (*Filesystem) GetChild ¶ added in v0.12.0
GetChild fetches a named child of an item. Wraps GetChildrenID.
func (*Filesystem) GetChildrenID ¶ added in v0.12.0
GetChildrenID grabs all DriveItems that are the children of the given ID. If items are not found, they are fetched.
func (*Filesystem) GetChildrenPath ¶ added in v0.12.0
GetChildrenPath grabs all DriveItems that are the children of the resource at the path. If items are not found, they are fetched.
func (*Filesystem) GetID ¶ added in v0.12.0
func (f *Filesystem) GetID(id string) *Inode
GetID gets an inode from the cache by ID. No API fetching is performed. Result is nil if no inode is found.
func (*Filesystem) GetNodeID ¶ added in v0.12.0
func (f *Filesystem) GetNodeID(nodeID uint64) *Inode
GetNodeID fetches the inode for a particular inode ID.
func (*Filesystem) GetPath ¶ added in v0.12.0
GetPath fetches a given DriveItem in the cache, if any items along the way are not found, they are fetched.
func (*Filesystem) InsertChild ¶ added in v0.12.0
func (f *Filesystem) InsertChild(parentID string, child *Inode) uint64
InsertChild adds an item as a child of a specified parent ID.
func (*Filesystem) InsertID ¶ added in v0.12.0
func (f *Filesystem) InsertID(id string, inode *Inode) uint64
InsertID inserts a single item into the filesystem by ID and sets its parent using the Inode.Parent.ID, if set. Must be called after DeleteID, if being used to rename/move an item. This is the main way new Inodes are added to the filesystem. Returns the Inode's numeric NodeID.
func (*Filesystem) InsertNodeID ¶ added in v0.12.0
func (f *Filesystem) InsertNodeID(inode *Inode) uint64
InsertNodeID assigns a numeric inode ID used by the kernel if one is not already assigned.
func (*Filesystem) InsertPath ¶ added in v0.12.0
InsertPath lets us manually insert an item to the cache (like if it was created locally). Overwrites a cached item if present. Must be called after delete if being used to move/rename an item.
func (*Filesystem) IsOffline ¶ added in v0.12.0
func (f *Filesystem) IsOffline() bool
IsOffline returns whether or not the cache thinks its offline.
func (*Filesystem) Lookup ¶ added in v0.12.0
func (f *Filesystem) Lookup(cancel <-chan struct{}, in *fuse.InHeader, name string, out *fuse.EntryOut) fuse.Status
Lookup is called by the kernel when the VFS wants to know about a file inside a directory.
func (*Filesystem) Mkdir ¶ added in v0.12.0
func (f *Filesystem) Mkdir(cancel <-chan struct{}, in *fuse.MkdirIn, name string, out *fuse.EntryOut) fuse.Status
Mkdir creates a directory.
func (*Filesystem) Mknod ¶ added in v0.12.0
func (f *Filesystem) Mknod(cancel <-chan struct{}, in *fuse.MknodIn, name string, out *fuse.EntryOut) fuse.Status
Mknod creates a regular file. The server doesn't have this yet.
func (*Filesystem) MoveID ¶ added in v0.12.0
func (f *Filesystem) MoveID(oldID string, newID string) error
MoveID moves an item to a new ID name. Also responsible for handling the actual overwrite of the item's IDInternal field
func (*Filesystem) MovePath ¶ added in v0.12.0
func (f *Filesystem) MovePath(oldParent, newParent, oldName, newName string, auth *graph.Auth) error
MovePath moves an item to a new position.
func (*Filesystem) Open ¶ added in v0.12.0
Open fetches a Inodes's content and initializes the .Data field with actual data from the server.
func (*Filesystem) OpenDir ¶ added in v0.12.0
func (f *Filesystem) OpenDir(cancel <-chan struct{}, in *fuse.OpenIn, out *fuse.OpenOut) fuse.Status
ReadDir provides a list of all the entries in the directory
func (*Filesystem) Read ¶ added in v0.12.0
func (f *Filesystem) Read(cancel <-chan struct{}, in *fuse.ReadIn, buf []byte) (fuse.ReadResult, fuse.Status)
Read an inode's data like a file.
func (*Filesystem) ReadDir ¶ added in v0.12.0
func (f *Filesystem) ReadDir(cancel <-chan struct{}, in *fuse.ReadIn, out *fuse.DirEntryList) fuse.Status
ReadDir reads a directory entry. Usually doesn't get called (ReadDirPlus is typically used).
func (*Filesystem) ReadDirPlus ¶ added in v0.12.0
func (f *Filesystem) ReadDirPlus(cancel <-chan struct{}, in *fuse.ReadIn, out *fuse.DirEntryList) fuse.Status
ReadDirPlus reads an individual directory entry AND does a lookup.
func (*Filesystem) ReleaseDir ¶ added in v0.12.0
func (f *Filesystem) ReleaseDir(in *fuse.ReleaseIn)
ReleaseDir closes a directory and purges it from memory
func (*Filesystem) Rename ¶ added in v0.12.0
func (f *Filesystem) Rename(cancel <-chan struct{}, in *fuse.RenameIn, name string, newName string) fuse.Status
Rename renames and/or moves an inode.
func (*Filesystem) SerializeAll ¶ added in v0.12.0
func (f *Filesystem) SerializeAll()
SerializeAll dumps all inode metadata currently in the cache to disk. This metadata is only used later if an item could not be found in memory AND the cache is offline. Old metadata is not removed, only overwritten (to avoid an offline session from wiping all metadata on a subsequent serialization).
func (*Filesystem) SetAttr ¶ added in v0.12.0
func (f *Filesystem) SetAttr(cancel <-chan struct{}, in *fuse.SetAttrIn, out *fuse.AttrOut) fuse.Status
Setattr is the workhorse for setting filesystem attributes. Does the work of operations like utimens, chmod, chown (not implemented, FUSE is single-user), and truncate.
func (*Filesystem) StatFs ¶ added in v0.12.0
func (f *Filesystem) StatFs(cancel <-chan struct{}, in *fuse.InHeader, out *fuse.StatfsOut) fuse.Status
Statfs returns information about the filesystem. Mainly useful for checking quotas and storage limits.
func (*Filesystem) TranslateID ¶ added in v0.12.0
func (f *Filesystem) TranslateID(nodeID uint64) string
TranslateID returns the DriveItemID for a given NodeID
type Inode ¶
Inode represents a file or folder fetched from the Graph API. All struct fields are pointers so as to avoid including them when marshaling to JSON if not present. The embedded DriveItem's fields should never be accessed, they are there for JSON umarshaling/marshaling only. (They are not safe to access concurrently.) This struct's methods are thread-safe and can be called concurrently. Reads/writes are done directly to DriveItems instead of implementing something like the fs.FileHandle to minimize the complexity of operations like Flush.
func NewInodeDriveItem ¶
NewInodeDriveItem creates a new Inode from a DriveItem
func NewInodeJSON ¶
NewInodeJSON converts JSON to a *DriveItem when loading from local storage. Not used with the API. FIXME: If implemented as UnmarshalJSON, this will break delta syncs for business accounts. Don't ask me why.
func (*Inode) AsJSON ¶
AsJSON converts a DriveItem to JSON for use with local storage. Not used with the API. FIXME: If implemented as MarshalJSON, this will break delta syncs for business accounts. Don't ask me why.
func (*Inode) HasChanges ¶
HasChanges returns true if the file has local changes that haven't been uploaded yet.
func (*Inode) HasChildren ¶ added in v0.9.0
HasChildren returns true if the item has more than 0 children
func (*Inode) ModTime ¶
ModTime returns the Unix timestamp of last modification (to get a time.Time struct, use time.Unix(int64(d.ModTime()), 0))
func (*Inode) NLink ¶
NLink gives the number of hard links to an inode (or child count if a directory)
func (*Inode) SetNodeID ¶ added in v0.12.0
SetNodeID sets the inode ID for an inode if not already set. Does nothing if the Inode already has an ID.
type LoopbackCache ¶ added in v0.14.0
type LoopbackCache struct {
// contains filtered or unexported fields
}
LoopbackCache stores the content for files under a folder as regular files
func NewLoopbackCache ¶ added in v0.14.0
func NewLoopbackCache(directory string) *LoopbackCache
func (*LoopbackCache) Close ¶ added in v0.14.0
func (l *LoopbackCache) Close(id string)
Close closes the currently open fd
func (*LoopbackCache) Delete ¶ added in v0.14.0
func (l *LoopbackCache) Delete(id string) error
Delete closes the fd AND deletes content from disk.
func (*LoopbackCache) Get ¶ added in v0.14.0
func (l *LoopbackCache) Get(id string) []byte
Get reads a file's content from disk.
func (*LoopbackCache) HasContent ¶ added in v0.14.0
func (l *LoopbackCache) HasContent(id string) bool
HasContent is used to find if we have a file or not in cache (in any state)
func (*LoopbackCache) Insert ¶ added in v0.14.0
func (l *LoopbackCache) Insert(id string, content []byte) error
InsertContent writes file content to disk in a single bulk insert.
func (*LoopbackCache) InsertStream ¶ added in v0.14.0
InsertStream inserts a stream of data
func (*LoopbackCache) IsOpen ¶ added in v0.14.0
func (l *LoopbackCache) IsOpen(id string) bool
IsOpen returns true if the file is already opened somewhere
type SerializeableInode ¶
SerializeableInode is like a Inode, but can be serialized for local storage to disk
type UploadManager ¶
type UploadManager struct {
// contains filtered or unexported fields
}
UploadManager is used to manage and retry uploads.
func NewUploadManager ¶
func NewUploadManager(duration time.Duration, db *bolt.DB, fs *Filesystem, auth *graph.Auth) *UploadManager
NewUploadManager creates a new queue/thread for uploads
func (*UploadManager) CancelUpload ¶ added in v0.9.0
func (u *UploadManager) CancelUpload(id string)
CancelUpload is used to kill any pending uploads for a session
func (*UploadManager) QueueUpload ¶
func (u *UploadManager) QueueUpload(inode *Inode) error
QueueUpload queues an item for upload.
type UploadSession ¶
type UploadSession struct { ID string `json:"id"` OldID string `json:"oldID"` ParentID string `json:"parentID"` NodeID uint64 `json:"nodeID"` Name string `json:"name"` ExpirationDateTime time.Time `json:"expirationDateTime"` Size uint64 `json:"size,omitempty"` Data []byte `json:"data,omitempty"` QuickXORHash string `json:"quickxorhash,omitempty"` ModTime time.Time `json:"modTime,omitempty"` sync.Mutex UploadURL string `json:"uploadUrl"` ETag string `json:"eTag,omitempty"` // contains filtered or unexported fields }
UploadSession contains a snapshot of the file we're uploading. We have to take the snapshot or the file may have changed on disk during upload (which would break the upload). It is not recommended to directly deserialize into this structure from API responses in case Microsoft ever adds a size, data, or modTime field to the response.
func NewUploadSession ¶
func NewUploadSession(inode *Inode, data *[]byte) (*UploadSession, error)
NewUploadSession wraps an upload of a file into an UploadSession struct responsible for performing uploads for a file.
func (*UploadSession) MarshalJSON ¶ added in v0.9.0
func (u *UploadSession) MarshalJSON() ([]byte, error)
MarshalJSON implements a custom JSON marshaler to avoid race conditions
func (*UploadSession) Upload ¶
func (u *UploadSession) Upload(auth *graph.Auth) error
Upload copies the file's contents to the server. Should only be called as a goroutine, or it can potentially block for a very long time. The uploadSession.error field contains errors to be handled if called as a goroutine.
type UploadSessionPost ¶
type UploadSessionPost struct { Name string `json:"name,omitempty"` ConflictBehavior string `json:"@microsoft.graph.conflictBehavior,omitempty"` FileSystemInfo `json:"fileSystemInfo,omitempty"` }
UploadSessionPost is the initial post used to create an upload session
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package graph provides the basic APIs to interact with Microsoft Graph.
|
Package graph provides the basic APIs to interact with Microsoft Graph. |
quickxorhash
Package quickxorhash provides the quickXorHash algorithm which is a quick, simple non-cryptographic hash algorithm that works by XORing the bytes in a circular-shifting fashion.
|
Package quickxorhash provides the quickXorHash algorithm which is a quick, simple non-cryptographic hash algorithm that works by XORing the bytes in a circular-shifting fashion. |