From a6d0537d3731b6dff37186cc1090ddb07f1767bd Mon Sep 17 00:00:00 2001 From: Lawrence Murray Date: Wed, 18 Sep 2024 21:15:49 +0700 Subject: [PATCH] Make use of XAttr included in the Link object, rather than getting it with an extra API request. --- file.go | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/file.go b/file.go index d045d81..a140c9f 100644 --- a/file.go +++ b/file.go @@ -48,25 +48,19 @@ func (protonDrive *ProtonDrive) GetActiveRevisionAttrs(ctx context.Context, link return nil, ErrLinkMustNotBeNil } - revisionsMetadata, err := protonDrive.GetRevisions(ctx, link, proton.RevisionStateActive) - if err != nil { - return nil, err - } - - if len(revisionsMetadata) != 1 { - return nil, ErrCantFindActiveRevision - } + revisionMetadata := link.FileProperties.ActiveRevision + revisionMetadata.XAttr = link.XAttr nodeKR, err := protonDrive.getLinkKR(ctx, link) if err != nil { return nil, err } - signatureVerificationKR, err := protonDrive.getSignatureVerificationKeyring([]string{link.FileProperties.ActiveRevision.SignatureEmail}) + signatureVerificationKR, err := protonDrive.getSignatureVerificationKeyring([]string{revisionMetadata.SignatureEmail}) if err != nil { return nil, err } - revisionXAttrCommon, err := revisionsMetadata[0].GetDecXAttrString(signatureVerificationKR, nodeKR) + revisionXAttrCommon, err := revisionMetadata.GetDecXAttrString(signatureVerificationKR, nodeKR) if err != nil { return nil, err }