]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Panic if renaming from and to same file
authorMatt Joiner <anacrolix@gmail.com>
Thu, 29 May 2025 08:42:57 +0000 (18:42 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Thu, 29 May 2025 08:42:57 +0000 (18:42 +1000)
storage/file-piece.go

index fe8cd6ba07562c223f369bd332fda5e663a3e66e..d52e70351cef59752774111070bb2fede09644b1 100644 (file)
@@ -209,6 +209,7 @@ func (me *filePieceImpl) exclRenameIfExists(from, to string) error {
                        return err
                }
        }
+       panicif.Eq(from, to)
        // We don't want anyone reading or writing to this until the rename completes.
        f, err := os.OpenFile(to, os.O_CREATE|os.O_EXCL, 0)
        if errors.Is(err, fs.ErrExist) {