folder

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package folder keeps backups in a folder of this computer, most often one that a sync client (iCloud Drive, OneDrive, Dropbox, Nextcloud, Syncthing…) carries to the user's other devices. A backup is done once it is written here; the sync client uploads it afterwards.

Index

Constants

View Source
const ICloudDrive = "iCloud"

ICloudDrive is the name Known gives iCloud Drive.

Variables

View Source
var (
	// ErrPath reports a folder that is not given by its full path.
	ErrPath = errors.New("folder: not a full path")
	// ErrDenied reports a folder this process may not read or write.
	ErrDenied = errors.New("folder: permission denied")
)

Functions

This section is empty.

Types

type Folder

type Folder struct {
	// Dir is the folder's full path; it is made when missing, as long as
	// its parent is there.
	Dir string
}

Folder is a folder of this computer that keeps backups.

func (*Folder) Check

func (f *Folder) Check(ctx context.Context) error

Check finds the folder, or its parent while it is not made yet.

func (*Folder) Delete

func (f *Folder) Delete(ctx context.Context, name string) error

Delete removes the backup name, or its placeholder, which has iCloud Drive delete it.

func (*Folder) Get

func (f *Folder) Get(ctx context.Context, name string) ([]byte, error)

Get reads the backup name, first asking iCloud Drive to download it when only its placeholder is here.

func (*Folder) List

func (f *Folder) List(ctx context.Context) ([]backup.Object, error)

List is the backups in the folder, none while it is not made. A backup iCloud Drive keeps only in the cloud is listed, its size unknown.

func (*Folder) Put

func (f *Folder) Put(ctx context.Context, name string, data []byte) error

Put writes the backup name, making the folder when it is missing. It is written under a hidden name first, so that neither a sync client nor another device's List sees half of it.

type Place

type Place struct {
	// Name is the sync client's, which is not translated.
	Name string
	// Path is the folder's full path.
	Path string
}

Place is a sync client's folder found on this computer.

func Known

func Known(goos, home string, getenv func(string) string) []Place

Known are the sync clients' folders on this computer, iCloud Drive first, for the operating system goos, the user's home and environment getenv. Only folders that are there are given.

func PlaceOf

func PlaceOf(places []Place, dir string) (Place, bool)

PlaceOf is the known place holding dir, if any.

Jump to

Keyboard shortcuts

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