libfs

package
v2.11.3+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 7, 2021 License: BSD-3-Clause Imports: 33 Imported by: 0

README

Common library code useful to any file system presentation layer for KBFS.

(TODO: Fill in more details.)

Documentation

Index

Constants

View Source
const (
	// InitErrorCode is the error code for initialization errors
	InitErrorCode = 1
	// MountErrorCode is the error code for mount errors
	MountErrorCode = 2
)
View Source
const (
	HumanErrorFileName   = "kbfs.error.txt"
	HumanNoLoginFileName = "kbfs.nologin.txt"
)

Special files in root directory.

View Source
const ArchivedRelTimeFilePrefix = ".kbfs_archived_reltime="

ArchivedRelTimeFilePrefix is the prefix to the file at the root of a TLF that contains the directory name of an archived revision described by the given relative time.

View Source
const ArchivedRevDirPrefix = ".kbfs_archived_rev="

ArchivedRevDirPrefix is the prefix to the directory at the root of a TLF that exposes a version of that TLF at the specified revision.

View Source
const ArchivedTimeLinkPrefix = ".kbfs_archived_time="

ArchivedTimeLinkPrefix is the prefix to the symlink at the root of a TLF that links to a version of that TLF at the specified time.

View Source
const DisableAutoJournalsFileName = ".kbfs_disable_auto_journals"

DisableAutoJournalsFileName is the name of the KBFS-wide auto-journal-disabling file. It's accessible anywhere outside a TLF.

View Source
const DisableBlockPrefetchingFileName = ".kbfs_disable_block_prefetching"

DisableBlockPrefetchingFileName is the name of the KBFS-wide prefetching-disabling file. It's accessible anywhere outside a TLF.

View Source
const DisableDebugServerFileName = ".kbfs_disable_debug_server"

DisableDebugServerFileName is the name of the file to turn on the debug HTTP server. It's accessible anywhere outside a TLF.

View Source
const DisableJournalFileName = ".kbfs_disable_journal"

DisableJournalFileName is the name of the journal-disabling file. It can be reached anywhere within a top-level folder.

View Source
const DisableSyncFileName = ".kbfs_disable_sync"

DisableSyncFileName is the name of the file to disable the sync cache for a TLF. It can be reached anywhere within a TLF.

View Source
const DisableUpdatesFileName = ".kbfs_disable_updates"

DisableUpdatesFileName is the name of the KBFS update-disabling file -- it can be reached anywhere within a top-level folder.

View Source
const EditHistoryName = ".kbfs_edit_history"

EditHistoryName is the name of the KBFS TLF edit history file -- it can be reached anywhere within a top-level folder.

View Source
const EnableAutoJournalsFileName = ".kbfs_enable_auto_journals"

EnableAutoJournalsFileName is the name of the KBFS-wide auto-journal-enabling file. It's accessible anywhere outside a TLF.

View Source
const EnableBlockPrefetchingFileName = ".kbfs_enable_block_prefetching"

EnableBlockPrefetchingFileName is the name of the KBFS-wide prefetching-enabling file. It's accessible anywhere outside a TLF.

View Source
const EnableDebugServerFileName = ".kbfs_enable_debug_server"

EnableDebugServerFileName is the name of the file to turn on the debug HTTP server. It's accessible anywhere outside a TLF.

View Source
const EnableJournalFileName = ".kbfs_enable_journal"

EnableJournalFileName is the name of the journal-enabling file. It can be reached anywhere within a top-level folder.

View Source
const EnableSyncFileName = ".kbfs_enable_sync"

EnableSyncFileName is the name of the file to enable the sync cache for a TLF. It can be reached anywhere within a TLF.

View Source
const EnableUpdatesFileName = ".kbfs_enable_updates"

EnableUpdatesFileName is the name of the KBFS update-enabling file -- it can be reached anywhere within a top-level folder.

View Source
const FileInfoPrefix = ".kbfs_fileinfo_"

FileInfoPrefix is the prefix of the per-file metadata files.

View Source
const FlushJournalFileName = ".kbfs_flush_journal"

FlushJournalFileName is the name of the journal-flushing file. It can be reached anywhere within a top-level folder.

View Source
const MetricsFileName = ".kbfs_metrics"

MetricsFileName is the name of the KBFS metrics file -- it can be reached from any KBFS directory.

View Source
const PauseJournalBackgroundWorkFileName = ".kbfs_pause_journal_background_work"

PauseJournalBackgroundWorkFileName is the name of the file that pauses the background work of a journal. It can be reached anywhere within a top-level folder.

View Source
const ProfileListDirName = ".kbfs_profiles"

ProfileListDirName is the name of the KBFS profile directory -- it can be reached from any KBFS directory.

View Source
const ReclaimQuotaFileName = ".kbfs_reclaim_quota"

ReclaimQuotaFileName is the name of the KBFS quota-reclaiming file -- it can be reached anywhere within a top-level folder.

View Source
const RekeyFileName = ".kbfs_rekey"

RekeyFileName is the name of the KBFS rekeying file -- it can be reached anywhere within a top-level folder.

View Source
const ResetCachesFileName = ".kbfs_reset_caches"

ResetCachesFileName is the name of the KBFS unstaging file.

View Source
const ResumeJournalBackgroundWorkFileName = ".kbfs_resume_journal_background_work"

ResumeJournalBackgroundWorkFileName is the name of the file that resumes the background work of a journal. It can be reached anywhere within a top-level folder.

View Source
const StatusFileName = ".kbfs_status"

StatusFileName is the name of the KBFS status file -- it can be reached anywhere within a top-level folder or inside the Keybase root

View Source
const SyncFromServerFileName = ".kbfs_sync_from_server"

SyncFromServerFileName is the name of the KBFS sync-from-server file -- it can be reached anywhere within a top-level folder.

View Source
const UnstageFileName = ".kbfs_unstage"

UnstageFileName is the name of the KBFS unstaging file -- it can be reached anywhere within a top-level folder.

View Source
const UpdateHistoryFileName = ".kbfs_update_history"

UpdateHistoryFileName is the name of the KBFS update history -- it can be reached anywhere within a top-level folder.

Variables

View Source
var ErrUnknownPrefetchStatus = errors.New(
	"Failed to determine prefetch status")

ErrUnknownPrefetchStatus is returned when the prefetch status given by the KBFSOps's NodeMetadata is invalid.

Functions

func BranchNameFromArchiveRefDir

func BranchNameFromArchiveRefDir(dir string) (libkbfs.BranchName, bool)

BranchNameFromArchiveRefDir returns a branch name and true if the given directory name is specifying an archived revision with a revision number.

func EnableFastMode

func EnableFastMode(ctx context.Context) context.Context

EnableFastMode returns a context.Context based on ctx that will test to true with IsFastModeEnabled.

func FileDataFromRelativeTimeString

func FileDataFromRelativeTimeString(
	ctx context.Context, config libkbfs.Config, h *libkbfs.TlfHandle,
	filename string) ([]byte, bool, error)

FileDataFromRelativeTimeString returns a byte string containing the name of a revision-based archive directory, and true, if the given file name specifies a valid by-relative-time file name. The time is relative to the local clock.

func FilterTLFEarlyExitError

func FilterTLFEarlyExitError(ctx context.Context, err error, log logger.Logger, name tlf.CanonicalName) (
	exitEarly bool, retErr error)

FilterTLFEarlyExitError decides whether an error received while trying to create a TLF should result in showing the user an empty folder (exitEarly == true), or not.

func GetEncodedErrors

func GetEncodedErrors(config libkbfs.Config) func(context.Context) ([]byte, time.Time, error)

GetEncodedErrors gets the list of encoded errors in a format suitable for error file.

func GetEncodedFolderStatus

func GetEncodedFolderStatus(ctx context.Context, config libkbfs.Config,
	folderBranch libkbfs.FolderBranch) (
	data []byte, t time.Time, err error)

GetEncodedFolderStatus returns serialized JSON containing status information for a folder

func GetEncodedMetrics

func GetEncodedMetrics(config libkbfs.Config) func(context.Context) ([]byte, time.Time, error)

GetEncodedMetrics returns metrics encoded as bytes for metrics file.

func GetEncodedStatus

func GetEncodedStatus(ctx context.Context, config libkbfs.Config) (
	data []byte, t time.Time, err error)

GetEncodedStatus returns serialized JSON containing top-level KBFS status information

func GetEncodedTlfEditHistory

func GetEncodedTlfEditHistory(ctx context.Context, config libkbfs.Config,
	folderBranch libkbfs.FolderBranch) (
	data []byte, t time.Time, err error)

GetEncodedTlfEditHistory returns serialized JSON containing the file edit history for a folder.

func GetEncodedUpdateHistory

func GetEncodedUpdateHistory(
	ctx context.Context, config libkbfs.Config,
	folderBranch libkbfs.FolderBranch) (
	data []byte, t time.Time, err error)

GetEncodedUpdateHistory returns a JSON-encoded version of a TLF's complete update history.

func GetEncodedUserEditHistory

func GetEncodedUserEditHistory(ctx context.Context, config libkbfs.Config) (
	data []byte, t time.Time, err error)

GetEncodedUserEditHistory returns serialized JSON containing the file edit history for the user.

func GetFileInfo

func GetFileInfo(
	ctx context.Context, config libkbfs.Config, dir libkbfs.Node, name string) (
	data []byte, t time.Time, err error)

GetFileInfo returns serialized JSON containing status information for a file or directory entry.

func IsFastModeEnabled

func IsFastModeEnabled(ctx context.Context) bool

IsFastModeEnabled returns true if fast mode should be enabled. In fast mode, *FS doesn't populate LastWriterUnverified, and always returns read-only info. All *FS created under this ctx will also be in fast mode.

func IsSupportedProfileName

func IsSupportedProfileName(name string) bool

IsSupportedProfileName matches a string against allowed profile names.

func IsWriter

func IsWriter(ctx context.Context, kbpki libkbfs.KBPKI,
	h *libkbfs.TlfHandle) (bool, error)

IsWriter returns whether or not the currently logged-in user is a valid writer for the folder described by `h`.

func LinkTargetFromTimeString

func LinkTargetFromTimeString(
	ctx context.Context, config libkbfs.Config, h *libkbfs.TlfHandle,
	link string) (string, bool, error)

LinkTargetFromTimeString returns the name of a by-revision archive directory, and true, if the given link specifies a valid by-time link name. Ambiguous dates are parsed in MM/DD format.

func ParseTlfHandlePreferredQuick

func ParseTlfHandlePreferredQuick(
	ctx context.Context, kbpki libkbfs.KBPKI, name string, ty tlf.Type) (
	handle *libkbfs.TlfHandle, err error)

ParseTlfHandlePreferredQuick parses a handle from a name, without doing this time consuming checks needed for implicit-team checking or TLF-ID-fetching.

func PrettyJSON

func PrettyJSON(value interface{}) ([]byte, error)

PrettyJSON marshals a value to human-readable JSON.

func ProfileGet

func ProfileGet(name string) func(context.Context) ([]byte, time.Time, error)

ProfileGet gets the relevant read function for the profile or nil if it doesn't exist.

func RevFromRelativeTimeString

func RevFromRelativeTimeString(
	ctx context.Context, config libkbfs.Config, h *libkbfs.TlfHandle,
	relTime string) (kbfsmd.Revision, error)

RevFromRelativeTimeString turns a string describing a time in the past relative to now (e.g., "5m", "2h55s"), and turns it into a revision number for the given TLF.

func RevFromTimeString

func RevFromTimeString(
	ctx context.Context, config libkbfs.Config, h *libkbfs.TlfHandle,
	timeString string) (kbfsmd.Revision, error)

RevFromTimeString converts a time string (in any supported golang date format) to the earliest revision number with a server timestamp greater or equal to that time. Ambiguous dates are parsed in MM/DD format.

func TimeEqual

func TimeEqual(a, b time.Time) bool

TimeEqual compares two filesystem-related timestamps.

On platforms that don't use nanosecond-accurate timestamps in their filesystem APIs, it truncates the timestamps to make them comparable.

func UnstageForTesting

func UnstageForTesting(ctx context.Context, log logger.Logger,
	config libkbfs.Config, fb libkbfs.FolderBranch,
	data []byte) (int, error)

UnstageForTesting unstages all unmerged commits and fast-forwards to the current master, if the given data is non-empty. If the given data is empty, it does nothing.

This should only be needed if there is a bug in automatic conflict resolution.

If the given data begins with the bytes "async", the unstaging is done asynchronously, i.e. this function returns immediately and the unstaging happens in the background. (Other subsequent IO operations may be blocked, though.) You can figure out when the unstage succeeds by consulting .kbfs_status.

func WritePermMode

func WritePermMode(
	ctx context.Context, node libkbfs.Node, original os.FileMode,
	kbpki libkbfs.KBPKI, h *libkbfs.TlfHandle) (os.FileMode, error)

WritePermMode fills in original based on whether or not the currently logged-in user is a valid writer for the folder described by `h`.

Types

type CtxAppIDType

type CtxAppIDType int

CtxAppIDType is the type used for the app ID context tag

const (
	// CtxAppIDKey is the context app id
	CtxAppIDKey CtxAppIDType = iota
)

type ErrNotADirectory

type ErrNotADirectory struct {
	Name string
}

ErrNotADirectory is returned when a non-final path element exists but is not a directory.

func (ErrNotADirectory) Error

func (e ErrNotADirectory) Error() string

type Error

type Error struct {
	Code    int
	Message string
}

Error defines errors with codes

func InitError

func InitError(message string) *Error

InitError is for initialization errors

func MountError

func MountError(message string) *Error

MountError is for mount errors

type FS

type FS struct {
	// contains filtered or unexported fields
}

FS is a wrapper around a KBFS subdirectory that implements the billy.Filesystem interface. It uses forward-slash separated paths. It may return errors wrapped with the `github.com/pkg/errors` package.

func NewFS

func NewFS(ctx context.Context, config libkbfs.Config,
	tlfHandle *libkbfs.TlfHandle, branch libkbfs.BranchName, subdir string,
	uniqID string, priority keybase1.MDPriority) (*FS, error)

NewFS returns a new FS instance, chroot'd to the given TLF and subdir within that TLF. `subdir` must exist, and point to a directory, before this function is called. `uniqID` needs to uniquely identify this instance among all users of this TLF globally; for example, a device ID combined with a local tempfile name is recommended.

func NewFSIfExists

func NewFSIfExists(ctx context.Context, config libkbfs.Config,
	tlfHandle *libkbfs.TlfHandle, branch libkbfs.BranchName, subdir string,
	uniqID string, priority keybase1.MDPriority) (*FS, error)

NewFSIfExists returns a new FS instance, chroot'd to the given TLF and subdir within that TLF, but only if the TLF already exists. `subdir` must exist, and point to a directory, before this function is called. `uniqID` needs to uniquely identify this instance among all users of this TLF globally; for example, a device ID combined with a local tempfile name is recommended.

If the TLF hasn't been initialized yet, this will return an FS that is always empty. `IsEmpty()` will tell if you this is happening. If there's a need to re-check the TLF, a new FS must be constructed.

func NewReadonlyFS

func NewReadonlyFS(ctx context.Context, config libkbfs.Config,
	tlfHandle *libkbfs.TlfHandle, branch libkbfs.BranchName, subdir string,
	uniqID string, priority keybase1.MDPriority) (*FS, error)

NewReadonlyFS returns a new FS instance, chroot'd to the given TLF and subdir within that TLF, but all the nodes are read-only. `subdir` must exist, and point to a directory, before this function is called. `uniqID` needs to uniquely identify this instance among all users of this TLF globally; for example, a device ID combined with a local tempfile name is recommended.

Note that this should only be used for subdirectories that will never be accessed in read-write mode by this process, because the nodes created via this FS might stay read-only in the libkbfs NodeCache for a while.

func NewUnwrappedFS

func NewUnwrappedFS(ctx context.Context, config libkbfs.Config,
	tlfHandle *libkbfs.TlfHandle, branch libkbfs.BranchName, subdir string,
	uniqID string, priority keybase1.MDPriority) (*FS, error)

NewUnwrappedFS returns a new FS instance, chroot'd to the given TLF and subdir within that TLF, but all the nodes are unwrapped. `subdir` must exist, and point to a directory, before this function is called. `uniqID` needs to uniquely identify this instance among all users of this TLF globally; for example, a device ID combined with a local tempfile name is recommended.

func (*FS) Chmod

func (fs *FS) Chmod(name string, mode os.FileMode) (err error)

Chmod implements the billy.Filesystem interface for FS.

func (*FS) Chown

func (fs *FS) Chown(name string, uid, gid int) error

Chown implements the billy.Filesystem interface for FS.

func (*FS) Chroot

func (fs *FS) Chroot(p string) (newFS billy.Filesystem, err error)

Chroot implements the billy.Filesystem interface for FS.

func (*FS) ChrootAsLibFS added in v1.0.44

func (fs *FS) ChrootAsLibFS(p string) (newFS *FS, err error)

ChrootAsLibFS returns a *FS whose root is p.

func (*FS) Chtimes

func (fs *FS) Chtimes(name string, atime time.Time, mtime time.Time) (
	err error)

Chtimes implements the billy.Filesystem interface for FS.

func (*FS) Config

func (fs *FS) Config() libkbfs.Config

Config returns the underlying Config object of this FS.

func (*FS) Create

func (fs *FS) Create(filename string) (billy.File, error)

Create implements the billy.Filesystem interface for FS.

func (*FS) GetLockNamespace

func (fs *FS) GetLockNamespace() (lockNamespace []byte)

GetLockNamespace returns the namespace used in locking.

func (*FS) IsEmpty

func (fs *FS) IsEmpty() bool

IsEmpty returns true if this is a faked-out empty TLF.

func (*FS) Join

func (fs *FS) Join(elem ...string) string

Join implements the billy.Filesystem interface for FS.

func (*FS) Lchown

func (fs *FS) Lchown(name string, uid, gid int) error

Lchown implements the billy.Filesystem interface for FS.

func (*FS) Lstat

func (fs *FS) Lstat(filename string) (fi os.FileInfo, err error)

Lstat implements the billy.Filesystem interface for FS.

func (*FS) MkdirAll

func (fs *FS) MkdirAll(filename string, perm os.FileMode) (err error)

MkdirAll implements the billy.Filesystem interface for FS.

func (*FS) Open

func (fs *FS) Open(filename string) (billy.File, error)

Open implements the billy.Filesystem interface for FS.

func (*FS) OpenFile

func (fs *FS) OpenFile(filename string, flag int, perm os.FileMode) (
	f billy.File, err error)

OpenFile implements the billy.Filesystem interface for FS.

func (*FS) ReadDir

func (fs *FS) ReadDir(p string) (fis []os.FileInfo, err error)

ReadDir implements the billy.Filesystem interface for FS.

func (fs *FS) Readlink(link string) (target string, err error)

Readlink implements the billy.Filesystem interface for FS.

func (*FS) Remove

func (fs *FS) Remove(filename string) (err error)

Remove implements the billy.Filesystem interface for FS.

func (*FS) Rename

func (fs *FS) Rename(oldpath, newpath string) (err error)

Rename implements the billy.Filesystem interface for FS.

func (*FS) Root

func (fs *FS) Root() string

Root implements the billy.Filesystem interface for FS.

func (*FS) RootNode added in v1.0.40

func (fs *FS) RootNode() libkbfs.Node

RootNode returns the Node of the root directory of this FS.

func (*FS) SetLockNamespace

func (fs *FS) SetLockNamespace(lockNamespace []byte)

SetLockNamespace sets the namespace used in locking.

func (*FS) Stat

func (fs *FS) Stat(filename string) (fi os.FileInfo, err error)

Stat implements the billy.Filesystem interface for FS.

func (*FS) SubscribeToEvents

func (fs *FS) SubscribeToEvents(ch chan<- FSEvent)

SubscribeToEvents causes *File objects constructed from this *FS to send events to the channel at beginning of Lock and Unlock. The send is done blockingly so caller needs to drain the channel properly or make it buffered with enough size.

func (*FS) SubscribeToObsolete added in v1.0.48

func (fs *FS) SubscribeToObsolete() (<-chan struct{}, error)

SubscribeToObsolete returns a channel that will be closed when this *FS reaches obsolescence, meaning if user of this object caches it for long term use, it should invalide this entry and create a new one using NewFS.

func (fs *FS) Symlink(target, link string) (err error)

Symlink implements the billy.Filesystem interface for FS.

func (*FS) SyncAll

func (fs *FS) SyncAll() error

SyncAll syncs any outstanding buffered writes to the KBFS journal.

func (*FS) TempFile

func (fs *FS) TempFile(dir, prefix string) (billy.File, error)

TempFile implements the billy.Filesystem interface for FS.

func (*FS) ToHTTPFileSystem added in v1.0.40

func (fs *FS) ToHTTPFileSystem(ctx context.Context) http.FileSystem

ToHTTPFileSystem calls fs.WithCtx with ctx to create a *FS with the new ctx, and returns a wrapper around it that satisfies the http.FileSystem interface.

func (*FS) UnsubscribeToEvents

func (fs *FS) UnsubscribeToEvents(ch chan<- FSEvent)

UnsubscribeToEvents stops *File objects constructed from this *FS from sending events to ch. It also closes ch.

func (*FS) WithContext added in v1.0.40

func (fs *FS) WithContext(ctx context.Context) *FS

WithContext returns a *FS based on fs, with its ctx replaced with ctx.

type FSEvent

type FSEvent struct {
	EventType FSEventType
	File      *File
	Done      <-chan struct{}
}

FSEvent is the type for events sent into the events channel passed into NewFS.

type FSEventType

type FSEventType int

FSEventType is FS event type.

const (

	// FSEventLock indicates Lock method has been called.
	FSEventLock FSEventType
	// FSEventUnlock indicates Unlock method has been called.
	FSEventUnlock
)

type FSNotifications

type FSNotifications struct {
	// contains filtered or unexported fields
}

FSNotifications processes notifications (arbitrary functions, usually triggered by libkbfs) and lets other objects block on them, usually for testing.

func NewFSNotifications

func NewFSNotifications(log logger.Logger) *FSNotifications

NewFSNotifications creates a new FSNotifications object.

func (*FSNotifications) LaunchProcessor

func (f *FSNotifications) LaunchProcessor(ctx context.Context)

LaunchProcessor launches the notification processor.

func (*FSNotifications) QueueNotification

func (f *FSNotifications) QueueNotification(fn func())

QueueNotification queues a notification, which must be goroutine-safe.

func (*FSNotifications) Wait

func (f *FSNotifications) Wait()

Wait waits until all current notifications are done.

type File

type File struct {
	// contains filtered or unexported fields
}

File is a wrapper around a libkbfs.Node that implements the billy.File interface.

func (*File) Close

func (f *File) Close() error

Close implements the billy.File interface for File.

func (*File) GetNode added in v1.0.40

func (f *File) GetNode() libkbfs.Node

GetNode returns the libkbfs.Node associated with this file.

func (*File) Lock

func (f *File) Lock() (err error)

Lock implements the billy.File interface for File.

func (*File) Name

func (f *File) Name() string

Name implements the billy.File interface for File.

func (*File) Read

func (f *File) Read(p []byte) (n int, err error)

Read implements the billy.File interface for File.

func (*File) ReadAt

func (f *File) ReadAt(p []byte, off int64) (n int, err error)

ReadAt implements the billy.File interface for File.

func (*File) Seek

func (f *File) Seek(offset int64, whence int) (n int64, err error)

Seek implements the billy.File interface for File.

func (*File) Truncate

func (f *File) Truncate(size int64) error

Truncate implements the billy.File interface for File.

func (*File) Unlock

func (f *File) Unlock() (err error)

Unlock implements the billy.File interface for File.

func (*File) Write

func (f *File) Write(p []byte) (n int, err error)

Write implements the billy.File interface for File.

type FileInfo

type FileInfo struct {
	// contains filtered or unexported fields
}

FileInfo is a wrapper around libkbfs.EntryInfo that implements the os.FileInfo interface.

func (*FileInfo) IsDir

func (fi *FileInfo) IsDir() bool

IsDir implements the os.FileInfo interface for FileInfo.

func (*FileInfo) ModTime

func (fi *FileInfo) ModTime() time.Time

ModTime implements the os.FileInfo interface for FileInfo.

func (*FileInfo) Mode

func (fi *FileInfo) Mode() os.FileMode

Mode implements the os.FileInfo interface for FileInfo.

func (*FileInfo) Name

func (fi *FileInfo) Name() string

Name implements the os.FileInfo interface for FileInfo.

func (*FileInfo) Size

func (fi *FileInfo) Size() int64

Size implements the os.FileInfo interface for FileInfo.

func (*FileInfo) Sys

func (fi *FileInfo) Sys() interface{}

Sys implements the os.FileInfo interface for FileInfo.

type FileInfoFast

type FileInfoFast struct {
	// contains filtered or unexported fields
}

FileInfoFast always returns a returns a read-only mode, and doesn't populate LastWriterUnverified. This allows us to avoid doing a Lookup on the entry, which makes a big difference in ReadDir.

func (*FileInfoFast) IsDir

func (fif *FileInfoFast) IsDir() bool

IsDir implements the os.FileInfo interface.

func (*FileInfoFast) ModTime

func (fif *FileInfoFast) ModTime() time.Time

ModTime implements the os.FileInfo interface.

func (*FileInfoFast) Mode

func (fif *FileInfoFast) Mode() os.FileMode

Mode implements the os.FileInfo interface.

func (*FileInfoFast) Name

func (fif *FileInfoFast) Name() string

Name implements the os.FileInfo interface.

func (*FileInfoFast) Size

func (fif *FileInfoFast) Size() int64

Size implements the os.FileInfo interface.

func (*FileInfoFast) Sys

func (fif *FileInfoFast) Sys() interface{}

Sys implements the os.FileInfo interface.

type JSONReportedError

type JSONReportedError struct {
	Time  time.Time
	Error string
	Stack []goerrors.StackFrame
}

JSONReportedError stringifies the reported error before marshalling

type JournalAction

type JournalAction int

JournalAction enumerates all the possible actions to take on a TLF's journal.

const (
	// JournalEnable is to turn the journal on.
	JournalEnable JournalAction = iota
	// JournalFlush is to flush the journal.
	JournalFlush
	// JournalPauseBackgroundWork is to pause journal background
	// work.
	JournalPauseBackgroundWork
	// JournalResumeBackgroundWork is to resume journal background
	// work.
	JournalResumeBackgroundWork
	// JournalDisable is to disable the journal.
	JournalDisable
	// JournalEnableAuto is to turn on journals for all TLFs, persistently.
	JournalEnableAuto
	// JournalDisableAuto is to turn off automatic journaling for new TLFs.
	JournalDisableAuto
)

func (JournalAction) Execute

func (a JournalAction) Execute(
	ctx context.Context, jServer *libkbfs.JournalServer,
	tlfID tlf.ID, h *libkbfs.TlfHandle) error

Execute performs the action on the given JournalServer for the given TLF.

func (JournalAction) String

func (a JournalAction) String() string

type KBFSMetadataForSimpleFS

type KBFSMetadataForSimpleFS struct {
	LastWriter     keybase1.User
	PrefetchStatus keybase1.PrefetchStatus
}

KBFSMetadataForSimpleFS contains the KBFS metadata needed to answer a simpleFSStat call.

type KBFSMetadataForSimpleFSGetter

type KBFSMetadataForSimpleFSGetter interface {
	KBFSMetadataForSimpleFS() (KBFSMetadataForSimpleFS, error)
}

KBFSMetadataForSimpleFSGetter is an interface for something that can return the last KBFS writer and prefetch status of a directory entry.

type MountInterrupter

type MountInterrupter struct {
	// can be locked from external code too.
	sync.Mutex
	// contains filtered or unexported fields
}

MountInterrupter is for managing mounts with cancelation.

func NewMountInterrupter

func NewMountInterrupter(log logger.Logger) *MountInterrupter

NewMountInterrupter creates a new MountInterrupter.

func (*MountInterrupter) Done

func (mi *MountInterrupter) Done()

Done signals Wait and runs the unmounter if set by MountAndSetUnmount. It can be called multiple times with no harm. Each call triggers a call to the unmounter.

func (*MountInterrupter) MountAndSetUnmount

func (mi *MountInterrupter) MountAndSetUnmount(mounter Mounter) error

MountAndSetUnmount calls Mount and sets the unmount function to be called once if mount succeeds. If Done has already been called MountAndSetUnmount returns an error.

func (*MountInterrupter) Wait

func (mi *MountInterrupter) Wait()

Wait waits till Done is called.

type Mounter

type Mounter interface {
	// Mount a  filesystem.
	Mount() error
	// Unmount a mounted filesystem.
	Unmount() error
}

Mounter is the interface for filesystems to be mounted by MountInterrupter.

type PrevRevisionsGetter

type PrevRevisionsGetter interface {
	PrevRevisions() libkbfs.PrevRevisions
}

PrevRevisionsGetter is an interface for something that can return the previous revisions of an entry.

type RemoteStatus

type RemoteStatus struct {
	sync.Mutex
	// contains filtered or unexported fields
}

RemoteStatus is for maintaining status of various remote connections like keybase service and md-server.

func (*RemoteStatus) ExtraFileName

func (r *RemoteStatus) ExtraFileName() string

ExtraFileName returns the extra file name or an empty string for none.

func (*RemoteStatus) ExtraFileNameAndSize

func (r *RemoteStatus) ExtraFileNameAndSize() (string, int64)

ExtraFileNameAndSize returns the extra file name or an empty string for none and the size of the extra file.

func (*RemoteStatus) Init

Init a RemoteStatus and register it with libkbfs.

func (*RemoteStatus) NewSpecialReadFunc

func (r *RemoteStatus) NewSpecialReadFunc(ctx context.Context) ([]byte, time.Time, error)

NewSpecialReadFunc implements a special read file that contains human readable current status.

type RemoteStatusUpdater

type RemoteStatusUpdater interface {
	// UserChanged is called when the kbfs user is changed.
	// Either oldName or newName, or both may be empty.
	UserChanged(ctx context.Context, oldName, newName kbname.NormalizedUsername)
}

RemoteStatusUpdater has callbacks that will be called from libfs when kbfs status changes in interesting ways.

type SyncAction

type SyncAction int

SyncAction enumerates all the possible actions to take on a TLF's sync state.

const (
	// SyncEnable is to enable syncing for a TLF.
	SyncEnable SyncAction = iota
	// SyncDisable is to disable syncing for a TLF.
	SyncDisable
)

func (SyncAction) Execute

Execute performs the action on the given JournalServer for the given TLF.

func (SyncAction) String

func (a SyncAction) String() string

type TlfDoesNotExist

type TlfDoesNotExist struct{}

TlfDoesNotExist is a shortcut error for the cases a TLF does not exist and an early successful exit via FilterTLFEarlyExitError is wished.

func (TlfDoesNotExist) Error

func (TlfDoesNotExist) Error() string

Error - implement error interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL