iclouddrive

package
v1.74.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: MIT Imports: 28 Imported by: 6

Documentation

Overview

Package iclouddrive provides access to iCloud Drive and Photos

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 handles the authentication and configuration flow

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 NewFsPhotos added in v1.74.0

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

NewFsPhotos constructs an Fs for Photos from the path, container:path

func NewServiceFs added in v1.74.0

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

NewServiceFs creates a filesystem instance for the selected service

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) Disconnect added in v1.74.0

func (f *Fs) Disconnect(ctx context.Context) error

Disconnect clears authentication state and removes disk caches

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

type PhotosFs added in v1.74.0

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

PhotosFs represents a remote iCloud Photos server

func (*PhotosFs) ChangeNotify added in v1.74.0

func (f *PhotosFs) ChangeNotify(ctx context.Context, notifyFunc func(string, fs.EntryType), pollIntervalChan <-chan time.Duration)

ChangeNotify polls for changes and notifies the VFS when directories are modified

func (*PhotosFs) CreateDir added in v1.74.0

func (f *PhotosFs) CreateDir(ctx context.Context, pathID, leaf string) (newID string, err error)

CreateDir makes a directory with pathID as parent and name leaf

func (*PhotosFs) DirCacheFlush added in v1.74.0

func (f *PhotosFs) DirCacheFlush()

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

func (*PhotosFs) Disconnect added in v1.74.0

func (f *PhotosFs) Disconnect(ctx context.Context) error

Disconnect clears authentication state and removes disk caches

func (*PhotosFs) Features added in v1.74.0

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

Features returns the optional features of this Fs

func (*PhotosFs) FindLeaf added in v1.74.0

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

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

func (*PhotosFs) Hashes added in v1.74.0

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

Hashes returns the supported hash sets

func (*PhotosFs) List added in v1.74.0

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

List the objects and directories in dir into entries

func (*PhotosFs) ListR added in v1.74.0

func (f *PhotosFs) ListR(ctx context.Context, dir string, callback fs.ListRCallback) error

ListR lists the objects and directories of the Fs starting from dir recursively into out, calling callback for each batch of entries Albums are listed in parallel using a goroutine pool

func (*PhotosFs) Mkdir added in v1.74.0

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

Mkdir is not supported for this read-only backend

func (*PhotosFs) Name added in v1.74.0

func (f *PhotosFs) Name() string

Name of the remote (as passed into NewFs)

func (*PhotosFs) NewObject added in v1.74.0

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

NewObject finds the Object at remote. If it can't be found it returns the error fs.ErrorObjectNotFound

func (*PhotosFs) Precision added in v1.74.0

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

Precision of the object storage system

func (*PhotosFs) Put added in v1.74.0

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

Put is not supported for this read-only backend

func (*PhotosFs) Rmdir added in v1.74.0

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

Rmdir is not supported for this read-only backend

func (*PhotosFs) Root added in v1.74.0

func (f *PhotosFs) Root() string

Root of the remote (as passed into NewFs)

func (*PhotosFs) String added in v1.74.0

func (f *PhotosFs) String() string

String converts this Fs to a string

type PhotosObject added in v1.74.0

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

PhotosObject describes an iCloud Photos object

func (*PhotosObject) Fs added in v1.74.0

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

Fs returns the parent Fs

func (*PhotosObject) Hash added in v1.74.0

func (o *PhotosObject) Hash(ctx context.Context, ty hash.Type) (string, error)

Hash returns the hash of an object returning a lowercase hex string

func (*PhotosObject) Metadata added in v1.74.0

func (o *PhotosObject) Metadata(ctx context.Context) (fs.Metadata, error)

Metadata returns metadata for the photo object

func (*PhotosObject) ModTime added in v1.74.0

func (o *PhotosObject) ModTime(ctx context.Context) time.Time

ModTime returns the modification time of the object

func (*PhotosObject) Open added in v1.74.0

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

Open an object for read, fetching a fresh download URL via records/lookup

func (*PhotosObject) Remote added in v1.74.0

func (o *PhotosObject) Remote() string

Remote returns the remote path

func (*PhotosObject) Remove added in v1.74.0

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

Remove is not supported for this read-only backend

func (*PhotosObject) SetModTime added in v1.74.0

func (o *PhotosObject) SetModTime(ctx context.Context, modTime time.Time) error

SetModTime sets the modification time of the object

func (*PhotosObject) Size added in v1.74.0

func (o *PhotosObject) Size() int64

Size returns the size of an object in bytes

func (*PhotosObject) Storable added in v1.74.0

func (o *PhotosObject) Storable() bool

Storable returns a boolean as to whether this object is storable

func (*PhotosObject) String added in v1.74.0

func (o *PhotosObject) String() string

Return a string version

func (*PhotosObject) Update added in v1.74.0

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

Update is not supported for this read-only backend

type ServiceOptions added in v1.74.0

type ServiceOptions struct {
	Service string `config:"service"`
}

ServiceOptions defines the configuration for service selection

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