Merge pull request 'Assert 64 bit file sizes even on 32 bit systems' (#502) from autodownload into master
continuous-integration/drone/push Build is pending Details

Reviewed-on: #502
Reviewed-by: Dan Ballard <dan@openprivacy.ca>
This commit is contained in:
Sarah Jamie Lewis 2023-03-16 22:05:53 +00:00
commit e94964c583
1 changed files with 5 additions and 2 deletions

View File

@ -10,7 +10,6 @@ import (
"fmt" "fmt"
"io" "io"
"math" "math"
"math/bits"
"os" "os"
path "path/filepath" path "path/filepath"
"regexp" "regexp"
@ -65,7 +64,7 @@ func (f Functionality) OnEvent(ev event.Event, profile peer.CwtchPeer) {
// will be bound to the size advertised in manifest. // will be bound to the size advertised in manifest.
fileSizeLimitValue, fileSizeLimitExists := profile.GetScopedZonedAttribute(attr.LocalScope, attr.FilesharingZone, fmt.Sprintf("%v.limit", fileKey)) fileSizeLimitValue, fileSizeLimitExists := profile.GetScopedZonedAttribute(attr.LocalScope, attr.FilesharingZone, fmt.Sprintf("%v.limit", fileKey))
if fileSizeLimitExists { if fileSizeLimitExists {
fileSizeLimit, err := strconv.ParseUint(fileSizeLimitValue, 10, bits.UintSize) fileSizeLimit, err := strconv.ParseUint(fileSizeLimitValue, 10, 64)
if err == nil { if err == nil {
if manifest.FileSizeInBytes >= fileSizeLimit { if manifest.FileSizeInBytes >= fileSizeLimit {
log.Debugf("could not download file, size %v greater than limit %v", manifest.FileSizeInBytes, fileSizeLimitValue) log.Debugf("could not download file, size %v greater than limit %v", manifest.FileSizeInBytes, fileSizeLimitValue)
@ -91,7 +90,11 @@ func (f Functionality) OnEvent(ev event.Event, profile peer.CwtchPeer) {
})) }))
} }
} }
} else {
log.Errorf("error saving manifest: file size limit is incorrect: %v", err)
} }
} else {
log.Errorf("error saving manifest: could not find file size limit info")
} }
} else { } else {
log.Errorf("error saving manifest: %v", err) log.Errorf("error saving manifest: %v", err)