Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func (protonDrive *ProtonDrive) getLink(ctx context.Context, linkID string) (*pr
}

// no cached data, fetch
link, err := protonDrive.c.GetLink(ctx, protonDrive.MainShare.ShareID, linkID)
link, err := protonDrive.c.GetVolumeLink(ctx, protonDrive.MainShare.VolumeID, linkID)
if err != nil {
return nil, err
}
Expand Down
18 changes: 9 additions & 9 deletions delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"github.com/rclone/go-proton-api"
)

func (protonDrive *ProtonDrive) moveToTrash(ctx context.Context, parentLinkID string, linkIDs ...string) error {
err := protonDrive.c.TrashChildren(ctx, protonDrive.MainShare.ShareID, parentLinkID, linkIDs...)
func (protonDrive *ProtonDrive) moveToTrash(ctx context.Context, linkIDs ...string) error {
err := protonDrive.c.TrashVolumeLinks(ctx, protonDrive.MainShare.VolumeID, linkIDs...)
if err != nil {
return err
}
Expand All @@ -31,7 +31,7 @@ func (protonDrive *ProtonDrive) MoveFileToTrashByID(ctx context.Context, linkID
return ErrLinkTypeMustToBeFileType
}

return protonDrive.moveToTrash(ctx, fileLink.ParentLinkID, linkID)
return protonDrive.moveToTrash(ctx, linkID)
}

func (protonDrive *ProtonDrive) MoveFolderToTrashByID(ctx context.Context, linkID string, onlyOnEmpty bool) error {
Expand All @@ -46,7 +46,7 @@ func (protonDrive *ProtonDrive) MoveFolderToTrashByID(ctx context.Context, linkI
return ErrLinkTypeMustToBeFolderType
}

childrenLinks, err := protonDrive.c.ListChildren(ctx, protonDrive.MainShare.ShareID, linkID /* false: list only active ones */, false)
childrenLinks, err := protonDrive.c.ListVolumeChildren(ctx, protonDrive.MainShare.VolumeID, linkID /* false: list only active ones */, false)
if err != nil {
return err
}
Expand All @@ -57,7 +57,7 @@ func (protonDrive *ProtonDrive) MoveFolderToTrashByID(ctx context.Context, linkI
}
}

return protonDrive.moveToTrash(ctx, folderLink.ParentLinkID, linkID)
return protonDrive.moveToTrash(ctx, linkID)
}

// WARNING!!!!
Expand All @@ -66,7 +66,7 @@ func (protonDrive *ProtonDrive) MoveFolderToTrashByID(ctx context.Context, linkI
func (protonDrive *ProtonDrive) EmptyRootFolder(ctx context.Context) error {
protonDrive.ClearCache()

links, err := protonDrive.c.ListChildren(ctx, protonDrive.MainShare.ShareID, protonDrive.MainShare.LinkID, true)
links, err := protonDrive.c.ListVolumeChildren(ctx, protonDrive.MainShare.VolumeID, protonDrive.MainShare.LinkID, true)
if err != nil {
return err
}
Expand All @@ -79,7 +79,7 @@ func (protonDrive *ProtonDrive) EmptyRootFolder(ctx context.Context) error {
}
}

err := protonDrive.c.TrashChildren(ctx, protonDrive.MainShare.ShareID, protonDrive.MainShare.LinkID, linkIDs...)
err := protonDrive.c.TrashVolumeLinks(ctx, protonDrive.MainShare.VolumeID, linkIDs...)
if err != nil {
return err
}
Expand All @@ -93,7 +93,7 @@ func (protonDrive *ProtonDrive) EmptyRootFolder(ctx context.Context) error {
}
}

err := protonDrive.c.DeleteChildren(ctx, protonDrive.MainShare.ShareID, protonDrive.MainShare.LinkID, linkIDs...)
err := protonDrive.c.DeleteVolumeLinks(ctx, protonDrive.MainShare.VolumeID, linkIDs...)
if err != nil {
return err
}
Expand All @@ -106,7 +106,7 @@ func (protonDrive *ProtonDrive) EmptyRootFolder(ctx context.Context) error {
func (protonDrive *ProtonDrive) EmptyTrash(ctx context.Context) error {
protonDrive.ClearCache()

err := protonDrive.c.EmptyTrash(ctx, protonDrive.MainShare.ShareID)
err := protonDrive.c.EmptyVolumeTrash(ctx, protonDrive.MainShare.VolumeID)
if err != nil {
return err
}
Expand Down
5 changes: 4 additions & 1 deletion drive.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,12 @@ func NewProtonDrive(ctx context.Context, config *common.Config, authHandler prot
// log.Printf("all volumes %#v", volumes)

mainShareID := ""
mainVolumeID := ""
for i := range volumes {
// iOS drive: first active volume
if volumes[i].State == proton.VolumeStateActive {
mainShareID = volumes[i].Share.ShareID
mainVolumeID = volumes[i].VolumeID
}
}
// log.Println("total volumes", len(volumes), "mainShareID", mainShareID)
Expand All @@ -90,6 +92,7 @@ func NewProtonDrive(ctx context.Context, config *common.Config, authHandler prot
for i := range shares {
if shares[i].ShareID == mainShare.ShareID &&
shares[i].LinkID == mainShare.LinkID &&
shares[i].VolumeID == mainVolumeID &&
shares[i].Flags == proton.PrimaryShare &&
shares[i].Type == proton.ShareTypeMain {
mainShareCheck = true
Expand All @@ -111,7 +114,7 @@ func NewProtonDrive(ctx context.Context, config *common.Config, authHandler prot
Links also hold the file name (encrypted) and a hash of the name for name collisions.
Link data is encrypted with its owning Share keyring.
*/
rootLink, err := c.GetLink(ctx, mainShare.ShareID, mainShare.LinkID)
rootLink, err := c.GetVolumeLink(ctx, mainVolumeID, mainShare.LinkID)
if err != nil {
return nil, nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions file.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type FileSystemAttrs struct {
}

func (protonDrive *ProtonDrive) GetRevisions(ctx context.Context, link *proton.Link, revisionType proton.RevisionState) ([]*proton.RevisionMetadata, error) {
revisions, err := protonDrive.c.ListRevisions(ctx, protonDrive.MainShare.ShareID, link.LinkID)
revisions, err := protonDrive.c.ListVolumeRevisions(ctx, protonDrive.MainShare.VolumeID, link.LinkID)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -104,7 +104,7 @@ func (protonDrive *ProtonDrive) GetActiveRevisionWithAttrs(ctx context.Context,
return nil, nil, ErrCantFindActiveRevision
}

revision, err := protonDrive.c.GetRevisionAllBlocks(ctx, protonDrive.MainShare.ShareID, link.LinkID, revisionsMetadata[0].ID)
revision, err := protonDrive.c.GetVolumeRevisionAllBlocks(ctx, protonDrive.MainShare.VolumeID, link.LinkID, revisionsMetadata[0].ID)
if err != nil {
return nil, nil, err
}
Expand Down
Loading