local: fix incorrect conversion between integer types

This commit is contained in:
albertony 2024-08-17 18:01:30 +02:00
parent c8366dfef3
commit 4e708e59f2

View File

@ -129,10 +129,13 @@ func (o *Object) writeMetadataToFile(m fs.Metadata) (outErr error) {
} }
mode, hasMode := o.parseMetadataInt(m, "mode", 8) mode, hasMode := o.parseMetadataInt(m, "mode", 8)
if hasMode { if hasMode {
if mode >= 0 && uint(mode) <= math.MaxUint32 { if mode >= 0 {
err = os.Chmod(o.path, os.FileMode(mode)) umode := uint(mode)
if err != nil { if umode <= math.MaxUint32 {
outErr = fmt.Errorf("failed to change permissions: %w", err) err = os.Chmod(o.path, os.FileMode(umode))
if err != nil {
outErr = fmt.Errorf("failed to change permissions: %w", err)
}
} }
} }
} }