iclouddrive

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package iclouddrive implements the iCloud Drive backend

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Config

func Config(ctx context.Context, name string, m configmap.Mapper, config fs.ConfigIn) (*fs.ConfigOut, error)

Config configures the iCloud remote.

func NewFs

func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, error)

NewFs constructs an Fs from the path, container:path

func ReadCookies

func ReadCookies(raw string) []*http.Cookie

ReadCookies parses the raw cookie string and returns an array of http.Cookie objects.

Types

type Fs

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

Fs represents a remote icloud drive

func (*Fs) Copy

func (f *Fs) Copy(ctx context.Context, src fs.Object, remote string) (fs.Object, error)

Copy src to this remote using server-side copy operations.

This is stored with the remote path given.

It returns the destination Object and a possible error.

Will only be called if src.Fs().Name() == f.Name()

If it isn't possible then return fs.ErrorCantCopy

func (*Fs) CreateDir

func (f *Fs) CreateDir(ctx context.Context, pathID, leaf string) (string, error)

CreateDir makes a directory with pathID as parent and name leaf

This should be implemented by the backend and will be called by the dircache package when appropriate.

func (*Fs) DirCacheFlush

func (f *Fs) DirCacheFlush()

DirCacheFlush resets the directory cache - used in testing as an optional interface

func (*Fs) DirMove

func (f *Fs) DirMove(ctx context.Context, src fs.Fs, srcRemote, dstRemote string) error

DirMove moves src, srcRemote to this remote at dstRemote using server-side move operations.

Will only be called if src.Fs().Name() == f.Name()

If it isn't possible then return fs.ErrorCantDirMove

If destination exists then return fs.ErrorDirExists

func (*Fs) Features

func (f *Fs) Features() *fs.Features

Features implements fs.Fs.

func (*Fs) FindDir

func (f *Fs) FindDir(ctx context.Context, path string, create bool) (pathID string, etag string, err error)

FindDir finds the directory passed in returning the directory ID starting from pathID

func (*Fs) FindLeaf

func (f *Fs) FindLeaf(ctx context.Context, pathID string, leaf string) (pathIDOut string, found bool, err error)

FindLeaf finds a directory of name leaf in the folder with ID pathID

func (*Fs) FindPath

func (f *Fs) FindPath(ctx context.Context, remote string, create bool) (leaf, directoryID, etag string, err error)

FindPath finds the leaf and directoryID from a normalized path

func (*Fs) Hashes

func (f *Fs) Hashes() hash.Set

Hashes are not exposed anywhere

func (*Fs) IDJoin

func (f *Fs) IDJoin(id string, etag string) string

IDJoin joins the given ID and ETag into a single string with a "#" delimiter.

func (*Fs) List

func (f *Fs) List(ctx context.Context, dir string) (entries fs.DirEntries, err error)

List implements fs.Fs.

func (*Fs) Mkdir

func (f *Fs) Mkdir(ctx context.Context, dir string) error

Mkdir implements fs.Fs.

func (*Fs) Move

func (f *Fs) Move(ctx context.Context, src fs.Object, remote string) (fs.Object, error)

Move moves the src object to the specified remote.

func (*Fs) Name

func (f *Fs) Name() string

Name implements fs.Fs.

func (*Fs) NewObject

func (f *Fs) NewObject(ctx context.Context, remote string) (fs.Object, error)

NewObject creates a new fs.Object from a given remote string.

ctx: The context.Context for the function. remote: The remote string representing the object's location. Returns an fs.Object and an error.

func (*Fs) NewObjectFromDriveItem

func (f *Fs) NewObjectFromDriveItem(ctx context.Context, remote string, item *api.DriveItem) (fs.Object, error)

NewObjectFromDriveItem creates a new fs.Object from a given remote string and DriveItem.

ctx: The context.Context for the function. remote: The remote string representing the object's location. item: The optional DriveItem to use for initializing the Object. If nil, the function will read the metadata from the remote location. Returns an fs.Object and an error.

func (*Fs) Precision

func (f *Fs) Precision() time.Duration

Precision implements fs.Fs.

func (*Fs) Purge

func (f *Fs) Purge(ctx context.Context, dir string) error

Purge all files in the directory specified

Implement this if you have a way of deleting all the files quicker than just running Remove() on the result of List()

Return an error if it doesn't exist

func (*Fs) Put

func (f *Fs) Put(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) (fs.Object, error)

Put in to the remote path with the modTime given of the given size

When called from outside an Fs by rclone, src.Size() will always be >= 0. But for unknown-sized objects (indicated by src.Size() == -1), Put should either return an error or upload it properly (rather than e.g. calling panic).

May create the object even if it returns an error - if so will return the object and the error, otherwise will return nil and the error

func (*Fs) Rmdir

func (f *Fs) Rmdir(ctx context.Context, dir string) error

Rmdir implements fs.Fs.

func (*Fs) Root

func (f *Fs) Root() string

Root implements fs.Fs.

func (*Fs) String

func (f *Fs) String() string

String implements fs.Fs.

type Object

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

Object describes an icloud drive object

func (*Object) Fs

func (o *Object) Fs() fs.Info

Fs implements fs.Object.

func (*Object) Hash

func (o *Object) Hash(ctx context.Context, t hash.Type) (string, error)

Hash implements fs.Object.

func (*Object) ID

func (o *Object) ID() string

ID returns the ID of the Object if known, or "" if not

func (*Object) ModTime

func (o *Object) ModTime(context.Context) time.Time

ModTime implements fs.Object.

func (*Object) Open

func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (io.ReadCloser, error)

Open implements fs.Object.

func (*Object) Remote

func (o *Object) Remote() string

Remote implements fs.Object.

func (*Object) Remove

func (o *Object) Remove(ctx context.Context) error

Remove implements fs.Object.

func (*Object) SetModTime

func (o *Object) SetModTime(ctx context.Context, t time.Time) error

SetModTime implements fs.Object.

func (*Object) Size

func (o *Object) Size() int64

Size implements fs.Object.

func (*Object) Storable

func (o *Object) Storable() bool

Storable implements fs.Object.

func (*Object) String

func (o *Object) String() string

String implements fs.Object.

func (*Object) Update

func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) error

Update implements fs.Object.

type Options

type Options struct {
	AppleID    string               `config:"apple_id"`
	Password   string               `config:"password"`
	Photos     bool                 `config:"photos"`
	TrustToken string               `config:"trust_token"`
	Cookies    string               `config:"cookies"`
	ClientID   string               `config:"client_id"`
	Enc        encoder.MultiEncoder `config:"encoding"`
}

Options defines the configuration for this backend

Directories

Path Synopsis
Package api provides functionality for interacting with the iCloud API.
Package api provides functionality for interacting with the iCloud API.

Jump to

Keyboard shortcuts

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