libfs

package
v0.0.0-...-5f77811 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2016 License: BSD-3-Clause Imports: 16 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 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 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 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 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 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 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 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.

Variables

This section is empty.

Functions

func FilterTLFEarlyExitError

func FilterTLFEarlyExitError(ctx context.Context, err error, log logger.Logger, name libkbfs.CanonicalTlfName) (
	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 IsSupportedProfileName

func IsSupportedProfileName(name string) bool

IsSupportedProfileName matches a string against allowed profile names.

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 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.

Types

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 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 JSONReportedError

type JSONReportedError struct {
	Time  time.Time
	Error string
	Stack []errors.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
	// JournalDisable is to disable the journal.
	JournalDisable
)

func (JournalAction) Execute

func (a JournalAction) Execute(
	ctx context.Context, jServer *libkbfs.JournalServer,
	tlf libkbfs.TlfID) error

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

func (JournalAction) String

func (a JournalAction) String() string

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

func (r *RemoteStatus) Init(ctx context.Context, log logger.Logger, config libkbfs.Config)

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 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