mirror of
https://github.com/henrybear327/Proton-API-Bridge.git
synced 2026-04-19 22:36:52 -04:00
Add GetActiveRevisionAttrs
This commit is contained in:
35
file.go
35
file.go
@@ -49,6 +49,41 @@ func (protonDrive *ProtonDrive) GetRevisions(ctx context.Context, link *proton.L
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (protonDrive *ProtonDrive) GetActiveRevisionAttrs(ctx context.Context, link *proton.Link) (*FileSystemAttrs, error) {
|
||||
if link == nil {
|
||||
return nil, ErrLinkMustNotBeNil
|
||||
}
|
||||
|
||||
revisionsMetadata, err := protonDrive.GetRevisions(ctx, link, proton.RevisionStateActive)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(revisionsMetadata) != 1 {
|
||||
return nil, ErrCantFindActiveRevision
|
||||
}
|
||||
|
||||
nodeKR, err := protonDrive.getLinkKR(ctx, link)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
revisionXAttrCommon, err := revisionsMetadata[0].GetDecXAttrString(protonDrive.AddrKR, nodeKR)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
modificationTime, err := iso8601.ParseString(revisionXAttrCommon.ModificationTime)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &FileSystemAttrs{
|
||||
ModificationTime: modificationTime,
|
||||
Size: revisionXAttrCommon.Size,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (protonDrive *ProtonDrive) GetActiveRevisionWithAttrs(ctx context.Context, link *proton.Link) (*proton.Revision, *FileSystemAttrs, error) {
|
||||
if link == nil {
|
||||
return nil, nil, ErrLinkMustNotBeNil
|
||||
|
||||
2
go.mod
2
go.mod
@@ -4,7 +4,7 @@ go 1.18
|
||||
|
||||
require (
|
||||
github.com/ProtonMail/gopenpgp/v2 v2.7.1
|
||||
github.com/henrybear327/go-proton-api v0.0.0-20230713204536-b20157868398
|
||||
github.com/henrybear327/go-proton-api v0.0.0-20230713211354-02be61689e29
|
||||
github.com/relvacode/iso8601 v1.3.0
|
||||
)
|
||||
|
||||
|
||||
6
go.sum
6
go.sum
@@ -49,8 +49,10 @@ github.com/go-resty/resty/v2 v2.7.0/go.mod h1:9PWDzw47qPphMRFfhsyk0NnSgvluHcljSM
|
||||
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
|
||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/henrybear327/go-proton-api v0.0.0-20230713204536-b20157868398 h1:KRNcqkuumUTJfQmNjRCbkyf4JDc5aIeWF+RPimF82Dk=
|
||||
github.com/henrybear327/go-proton-api v0.0.0-20230713204536-b20157868398/go.mod h1:l42xBSOrCmkAxzWUHcoUsG/cP8m1hMhV72GoChOX3bg=
|
||||
github.com/henrybear327/go-proton-api v0.0.0-20230713200642-3b697f4742b7 h1:OkRwTLGmzs9oMzQC0tmnCbRN32QJI43RXdUua0uCQYQ=
|
||||
github.com/henrybear327/go-proton-api v0.0.0-20230713200642-3b697f4742b7/go.mod h1:l42xBSOrCmkAxzWUHcoUsG/cP8m1hMhV72GoChOX3bg=
|
||||
github.com/henrybear327/go-proton-api v0.0.0-20230713211354-02be61689e29 h1:OUVzxoIPZ6T4yC5hzvvIEjRaYwom3c9N5VwJgJvr9cs=
|
||||
github.com/henrybear327/go-proton-api v0.0.0-20230713211354-02be61689e29/go.mod h1:l42xBSOrCmkAxzWUHcoUsG/cP8m1hMhV72GoChOX3bg=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk=
|
||||
github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
|
||||
|
||||
Reference in New Issue
Block a user