Fix RevisionXAttrCommon digests related logic

This commit is contained in:
Chun-Hung Tseng
2023-07-23 08:25:17 +02:00
parent a33d554f70
commit e2f5412124
3 changed files with 23 additions and 7 deletions

22
file.go
View File

@@ -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 {

4
go.mod
View File

@@ -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

4
go.sum
View File

@@ -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=