From c24bb95af56401b324ffe19cebd3f474be42f194 Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Fri, 4 Feb 2022 13:19:47 -0800 Subject: [PATCH] Android: Change DownloadFile API to explictly use uint64 --- functionality/filesharing/filesharing_functionality.go | 4 ++-- peer/cwtch_peer.go | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/functionality/filesharing/filesharing_functionality.go b/functionality/filesharing/filesharing_functionality.go index 703d157..0902ba6 100644 --- a/functionality/filesharing/filesharing_functionality.go +++ b/functionality/filesharing/filesharing_functionality.go @@ -74,7 +74,7 @@ func (om *OverlayMessage) ShouldAutoDL() bool { // DownloadFile given a profile, a conversation handle and a file sharing key, start off a download process // to downloadFilePath -func (f *Functionality) DownloadFile(profile peer.CwtchPeer, conversationID int, downloadFilePath string, manifestFilePath string, key string, limit int) { +func (f *Functionality) DownloadFile(profile peer.CwtchPeer, conversationID int, downloadFilePath string, manifestFilePath string, key string, limit uint64) { // Store local.filesharing.filekey.manifest as the location of the manifest profile.SetScopedZonedAttribute(attr.LocalScope, attr.FilesharingZone, fmt.Sprintf("%s.manifest", key), manifestFilePath) @@ -83,7 +83,7 @@ func (f *Functionality) DownloadFile(profile peer.CwtchPeer, conversationID int, profile.SetScopedZonedAttribute(attr.LocalScope, attr.FilesharingZone, fmt.Sprintf("%s.path", key), downloadFilePath) // Store local.filesharing.filekey.limit as the max file size of the download - profile.SetScopedZonedAttribute(attr.LocalScope, attr.FilesharingZone, fmt.Sprintf("%s.limit", key), strconv.Itoa(limit)) + profile.SetScopedZonedAttribute(attr.LocalScope, attr.FilesharingZone, fmt.Sprintf("%s.limit", key), strconv.FormatUint(limit, 10)) // Get the value of conversation.filesharing.filekey.manifest.size from `handle` profile.SendScopedZonedGetValToContact(conversationID, attr.ConversationScope, attr.FilesharingZone, fmt.Sprintf("%s.manifest.size", key)) diff --git a/peer/cwtch_peer.go b/peer/cwtch_peer.go index b2e7d4e..186003c 100644 --- a/peer/cwtch_peer.go +++ b/peer/cwtch_peer.go @@ -14,6 +14,7 @@ import ( "git.openprivacy.ca/openprivacy/connectivity/tor" "golang.org/x/crypto/ed25519" "io/ioutil" + "math/bits" path "path/filepath" "runtime" "strconv" @@ -1147,9 +1148,9 @@ func (cp *cwtchPeer) eventHandler() { // will be bound to the size advertised in manifest. fileSizeLimitValue, fileSizeLimitExists := cp.GetScopedZonedAttribute(attr.LocalScope, attr.FilesharingZone, fmt.Sprintf("%v.limit", fileKey)) if fileSizeLimitExists { - fileSizeLimit, err := strconv.Atoi(fileSizeLimitValue) + fileSizeLimit, err := strconv.ParseUint(fileSizeLimitValue, 10, bits.UintSize) if err == nil { - if manifest.FileSizeInBytes >= uint64(fileSizeLimit) { + if manifest.FileSizeInBytes >= fileSizeLimit { log.Errorf("could not download file, size %v greater than limit %v", manifest.FileSizeInBytes, fileSizeLimitValue) } else { manifest.Title = manifest.FileName