From e2f54121245f84a92cef1aaf8bdf918f950cc459 Mon Sep 17 00:00:00 2001 From: Chun-Hung Tseng Date: Sun, 23 Jul 2023 08:25:17 +0200 Subject: [PATCH] Fix RevisionXAttrCommon digests related logic --- file.go | 22 +++++++++++++++++++--- go.mod | 4 ++-- go.sum | 4 ++-- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/file.go b/file.go index 5df24ce..b1cdde3 100644 --- a/file.go +++ b/file.go @@ -163,11 +163,18 @@ func (protonDrive *ProtonDrive) GetActiveRevisionAttrs(ctx context.Context, link return nil, err } + var sha1Hash string + if val, ok := revisionXAttrCommon.Digests["SHA1"]; ok { + sha1Hash = val + } else { + sha1Hash = "" + } + return &FileSystemAttrs{ ModificationTime: modificationTime, Size: revisionXAttrCommon.Size, BlockSizes: revisionXAttrCommon.BlockSizes, - Digests: revisionXAttrCommon.Digests, + Digests: sha1Hash, }, nil } @@ -205,11 +212,18 @@ func (protonDrive *ProtonDrive) GetActiveRevisionWithAttrs(ctx context.Context, return nil, nil, err } + var sha1Hash string + if val, ok := revisionXAttrCommon.Digests["SHA1"]; ok { + sha1Hash = val + } else { + sha1Hash = "" + } + return &revision, &FileSystemAttrs{ ModificationTime: modificationTime, Size: revisionXAttrCommon.Size, BlockSizes: revisionXAttrCommon.BlockSizes, - Digests: revisionXAttrCommon.Digests, + Digests: sha1Hash, }, nil } @@ -727,7 +741,9 @@ func (protonDrive *ProtonDrive) uploadFile(ctx context.Context, parentLink *prot ModificationTime: modTime.Format("2006-01-02T15:04:05-0700"), /* ISO8601 */ Size: fileSize, BlockSizes: blockSizes, - Digests: digests, + Digests: map[string]string{ + "SHA1": digests, + }, } err = protonDrive.commitNewRevision(ctx, newNodeKR, xAttrCommon, manifestSignature, linkID, revisionID) if err != nil { diff --git a/go.mod b/go.mod index 4e713ac..7e92000 100644 --- a/go.mod +++ b/go.mod @@ -3,15 +3,15 @@ module github.com/henrybear327/Proton-API-Bridge go 1.18 require ( + github.com/ProtonMail/gluon v0.17.0 github.com/ProtonMail/gopenpgp/v2 v2.7.2 - github.com/henrybear327/go-proton-api v0.0.0-20230717103708-031d819d74ab + github.com/henrybear327/go-proton-api v0.0.0-20230723062344-776bc2954583 github.com/relvacode/iso8601 v1.3.0 golang.org/x/sync v0.3.0 ) require ( github.com/ProtonMail/bcrypt v0.0.0-20211005172633-e235017c1baf // indirect - github.com/ProtonMail/gluon v0.17.0 // indirect github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95 // indirect github.com/ProtonMail/go-mime v0.0.0-20230322103455-7d82a3887f2f // indirect github.com/ProtonMail/go-srp v0.0.7 // indirect diff --git a/go.sum b/go.sum index 2c209b9..5b955c2 100644 --- a/go.sum +++ b/go.sum @@ -49,8 +49,8 @@ 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-20230717103708-031d819d74ab h1:Lj7+orKyKsOo3UwlopF+IxC7RWdyboAi800RWHiI8Ig= -github.com/henrybear327/go-proton-api v0.0.0-20230717103708-031d819d74ab/go.mod h1:l42xBSOrCmkAxzWUHcoUsG/cP8m1hMhV72GoChOX3bg= +github.com/henrybear327/go-proton-api v0.0.0-20230723062344-776bc2954583 h1:Bbv0iyHKIr2ZXSOKcG4Ja8Z+NxWKdOVqGSLd3/SQTLk= +github.com/henrybear327/go-proton-api v0.0.0-20230723062344-776bc2954583/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=