mirror of
https://github.com/matrix-org/dendrite
synced 2024-11-19 00:00:55 +01:00
mediaapi/fileutils: Fix and comment os.IsNotExist bug
This commit is contained in:
parent
63ccd770c6
commit
a4300eefc4
1 changed files with 3 additions and 1 deletions
|
@ -76,7 +76,9 @@ func MoveFileWithHashCheck(tmpDir types.Path, mediaMetadata *types.MediaMetadata
|
||||||
}
|
}
|
||||||
|
|
||||||
var stat os.FileInfo
|
var stat os.FileInfo
|
||||||
if stat, err = os.Stat(finalPath); os.IsExist(err) {
|
// Note: The double-negative is intentional as os.IsExist(err) != !os.IsNotExist(err).
|
||||||
|
// The functions are error checkers to be used in different cases.
|
||||||
|
if stat, err = os.Stat(finalPath); !os.IsNotExist(err) {
|
||||||
duplicate = true
|
duplicate = true
|
||||||
if stat.Size() == int64(mediaMetadata.FileSizeBytes) {
|
if stat.Size() == int64(mediaMetadata.FileSizeBytes) {
|
||||||
return types.Path(finalPath), duplicate, nil
|
return types.Path(finalPath), duplicate, nil
|
||||||
|
|
Loading…
Reference in a new issue