Documentation ¶
Index ¶
- Variables
- func NewDefaultConfig() *common.Config
- func RandomString(n int) string
- func StringFn(n int, randIntn func(n int) int) string
- type FileDownloadReader
- type FileSystemAttrs
- type MailSendingParameters
- type ProtonDirectoryData
- type ProtonDrive
- func (protonDrive *ProtonDrive) About(ctx context.Context) (*proton.User, error)
- func (protonDrive *ProtonDrive) ClearCache()
- func (protonDrive *ProtonDrive) CreateNewFolder(ctx context.Context, parentLink *proton.Link, folderName string) (string, error)
- func (protonDrive *ProtonDrive) CreateNewFolderByID(ctx context.Context, parentLinkID string, folderName string) (string, error)
- func (protonDrive *ProtonDrive) DownloadFile(ctx context.Context, link *proton.Link, offset int64) (io.ReadCloser, int64, *FileSystemAttrs, error)
- func (protonDrive *ProtonDrive) DownloadFileByID(ctx context.Context, linkID string, offset int64) (io.ReadCloser, int64, *FileSystemAttrs, error)
- func (protonDrive *ProtonDrive) EmptyRootFolder(ctx context.Context) error
- func (protonDrive *ProtonDrive) EmptyTrash(ctx context.Context) error
- func (protonDrive *ProtonDrive) GetActiveRevisionAttrs(ctx context.Context, link *proton.Link) (*FileSystemAttrs, error)
- func (protonDrive *ProtonDrive) GetActiveRevisionAttrsByID(ctx context.Context, linkID string) (*FileSystemAttrs, error)
- func (protonDrive *ProtonDrive) GetActiveRevisionWithAttrs(ctx context.Context, link *proton.Link) (*proton.Revision, *FileSystemAttrs, error)
- func (protonDrive *ProtonDrive) GetLink(ctx context.Context, linkID string) (*proton.Link, error)
- func (protonDrive *ProtonDrive) GetRevisions(ctx context.Context, link *proton.Link, revisionType proton.RevisionState) ([]*proton.RevisionMetadata, error)
- func (protonDrive *ProtonDrive) ListDirectory(ctx context.Context, folderLinkID string) ([]*ProtonDirectoryData, error)
- func (protonDrive *ProtonDrive) Logout(ctx context.Context) error
- func (protonDrive *ProtonDrive) MoveFile(ctx context.Context, srcLink *proton.Link, dstParentLink *proton.Link, ...) error
- func (protonDrive *ProtonDrive) MoveFileByID(ctx context.Context, srcLinkID, dstParentLinkID string, dstName string) error
- func (protonDrive *ProtonDrive) MoveFileToTrashByID(ctx context.Context, linkID string) error
- func (protonDrive *ProtonDrive) MoveFolder(ctx context.Context, srcLink *proton.Link, dstParentLink *proton.Link, ...) error
- func (protonDrive *ProtonDrive) MoveFolderByID(ctx context.Context, srcLinkID, dstParentLinkID, dstName string) error
- func (protonDrive *ProtonDrive) MoveFolderToTrashByID(ctx context.Context, linkID string, onlyOnEmpty bool) error
- func (protonDrive *ProtonDrive) SearchByNameInActiveFolder(ctx context.Context, folderLink *proton.Link, targetName string, ...) (*proton.Link, error)
- func (protonDrive *ProtonDrive) SearchByNameInActiveFolderByID(ctx context.Context, folderLinkID string, targetName string, ...) (*proton.Link, error)
- func (protonDrive *ProtonDrive) SearchByNameRecursively(ctx context.Context, folderLink *proton.Link, targetName string, isFolder bool, ...) (*proton.Link, error)
- func (protonDrive *ProtonDrive) SendEmail(ctx context.Context, i int, errChan chan error, config *MailSendingParameters)
- func (protonDrive *ProtonDrive) UploadFileByPath(ctx context.Context, parentLink *proton.Link, filename string, filePath string, ...) (string, *proton.RevisionXAttrCommon, error)
- func (protonDrive *ProtonDrive) UploadFileByReader(ctx context.Context, parentLinkID string, filename string, modTime time.Time, ...) (string, *proton.RevisionXAttrCommon, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( LIB_VERSION = "1.0.0" UPLOAD_BLOCK_SIZE = 4 * 1024 * 1024 // 4 MB UPLOAD_BATCH_BLOCK_SIZE = 8 /* https://github.com/rclone/rclone/pull/7093#issuecomment-1637024885 The idea is that rclone performs buffering / pre-fetching on it's own so we don't need to be doing this on our end. If you are not using rclone and instead is directly basing your work on this library, then maybe you can increase this value to let the library does the buffering work for you! */ DOWNLOAD_BATCH_BLOCK_SIZE = 1 )
View Source
var ( ErrDataFolderNameIsEmpty = errors.New("please supply a DataFolderName to enabling file downloading") ErrLinkTypeMustToBeFolderType = errors.New("the link type must be of folder type") ErrLinkTypeMustToBeFileType = errors.New("the link type must be of file type") ErrFolderIsNotEmpty = errors.New("folder can't be deleted because it is not empty") ErrCantLocateRevision = errors.New("can't create a new file upload request and can't find an active/draft revision") ErrInternalErrorOnFileUpload = errors.New("either link or file creation request should be not nil") ErrMissingInputUploadAndCollectBlockData = errors.New("missing either session key or key ring") ErrLinkMustNotBeNil = errors.New("missing input proton link") ErrLinkMustBeActive = errors.New("can not operate on link state other than active") ErrDownloadedBlockHashVerificationFailed = errors.New("the hash of the downloaded block doesn't match the original hash") ErrDraftExists = errors.New("a draft exist - usually this means a file is being uploaded at another client, or, there was a failed upload attempt. Can use --protondrive-replace-existing-draft=true to temporarily override the existing draft") ErrCantFindActiveRevision = errors.New("can't find an active revision") ErrCantFindDraftRevision = errors.New("can't find a draft revision") ErrWrongUsageOfGetLinkKR = errors.New("internal error for GetLinkKR - nil passed in for link") ErrWrongUsageOfGetLink = errors.New("internal error for getLink - empty linkID passed in") ErrSeekOffsetAfterSkippingBlocks = errors.New("internal error for download seek - the offset after skipping blocks is wrong") ErrNoKeyringForSignatureVerification = errors.New(("internal error for signature verification - no keyring is generated")) )
Functions ¶
func NewDefaultConfig ¶
func RandomString ¶
String create a random string for test purposes.
Do not use these for passwords.
func StringFn ¶
Taken from: https://github.com/rclone/rclone/blob/e43b5ce5e59b5717a9819ff81805dd431f710c10/lib/random/random.go
StringFn create a random string for test purposes using the random number generator function passed in.
Do not use these for passwords.
Types ¶
type FileDownloadReader ¶
type FileDownloadReader struct {
// contains filtered or unexported fields
}
func (*FileDownloadReader) Close ¶
func (r *FileDownloadReader) Close() error
type FileSystemAttrs ¶
type MailSendingParameters ¶
type ProtonDirectoryData ¶
type ProtonDrive ¶
type ProtonDrive struct { RootLink *proton.Link DefaultAddrKR *crypto.KeyRing Config *common.Config // contains filtered or unexported fields }
func NewProtonDrive ¶
func NewProtonDrive(ctx context.Context, config *common.Config, authHandler proton.AuthHandler, deAuthHandler proton.Handler) (*ProtonDrive, *common.ProtonDriveCredential, error)
func (*ProtonDrive) About ¶
func (protonDrive *ProtonDrive) About(ctx context.Context) (*proton.User, error)
func (*ProtonDrive) ClearCache ¶
func (protonDrive *ProtonDrive) ClearCache()
func (*ProtonDrive) CreateNewFolder ¶
func (*ProtonDrive) CreateNewFolderByID ¶
func (*ProtonDrive) DownloadFile ¶
func (protonDrive *ProtonDrive) DownloadFile(ctx context.Context, link *proton.Link, offset int64) (io.ReadCloser, int64, *FileSystemAttrs, error)
func (*ProtonDrive) DownloadFileByID ¶
func (protonDrive *ProtonDrive) DownloadFileByID(ctx context.Context, linkID string, offset int64) (io.ReadCloser, int64, *FileSystemAttrs, error)
func (*ProtonDrive) EmptyRootFolder ¶
func (protonDrive *ProtonDrive) EmptyRootFolder(ctx context.Context) error
WARNING!!!! Everything in the root folder will be moved to trash Most likely only used for debugging when the key is messed up
func (*ProtonDrive) EmptyTrash ¶
func (protonDrive *ProtonDrive) EmptyTrash(ctx context.Context) error
Empty the trash
func (*ProtonDrive) GetActiveRevisionAttrs ¶
func (protonDrive *ProtonDrive) GetActiveRevisionAttrs(ctx context.Context, link *proton.Link) (*FileSystemAttrs, error)
Might return nil when xattr is missing
func (*ProtonDrive) GetActiveRevisionAttrsByID ¶
func (protonDrive *ProtonDrive) GetActiveRevisionAttrsByID(ctx context.Context, linkID string) (*FileSystemAttrs, error)
func (*ProtonDrive) GetActiveRevisionWithAttrs ¶
func (protonDrive *ProtonDrive) GetActiveRevisionWithAttrs(ctx context.Context, link *proton.Link) (*proton.Revision, *FileSystemAttrs, error)
func (*ProtonDrive) GetLink ¶
func (protonDrive *ProtonDrive) GetLink(ctx context.Context, linkID string) (*proton.Link, error)
func (*ProtonDrive) GetRevisions ¶
func (protonDrive *ProtonDrive) GetRevisions(ctx context.Context, link *proton.Link, revisionType proton.RevisionState) ([]*proton.RevisionMetadata, error)
func (*ProtonDrive) ListDirectory ¶
func (protonDrive *ProtonDrive) ListDirectory( ctx context.Context, folderLinkID string) ([]*ProtonDirectoryData, error)
func (*ProtonDrive) MoveFile ¶
func (protonDrive *ProtonDrive) MoveFile(ctx context.Context, srcLink *proton.Link, dstParentLink *proton.Link, dstName string) error
func (*ProtonDrive) MoveFileByID ¶
func (*ProtonDrive) MoveFileToTrashByID ¶
func (protonDrive *ProtonDrive) MoveFileToTrashByID(ctx context.Context, linkID string) error
func (*ProtonDrive) MoveFolder ¶
func (protonDrive *ProtonDrive) MoveFolder(ctx context.Context, srcLink *proton.Link, dstParentLink *proton.Link, dstName string) error
func (*ProtonDrive) MoveFolderByID ¶
func (protonDrive *ProtonDrive) MoveFolderByID(ctx context.Context, srcLinkID, dstParentLinkID, dstName string) error
func (*ProtonDrive) MoveFolderToTrashByID ¶
func (*ProtonDrive) SearchByNameInActiveFolder ¶
func (*ProtonDrive) SearchByNameInActiveFolderByID ¶
func (protonDrive *ProtonDrive) SearchByNameInActiveFolderByID(ctx context.Context, folderLinkID string, targetName string, searchForFile, searchForFolder bool, targetState proton.LinkState) (*proton.Link, error)
if the target isn't found, nil will be returned for both return values
func (*ProtonDrive) SearchByNameRecursively ¶
func (*ProtonDrive) SendEmail ¶
func (protonDrive *ProtonDrive) SendEmail(ctx context.Context, i int, errChan chan error, config *MailSendingParameters)
func (*ProtonDrive) UploadFileByPath ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.