From: Matt Joiner Date: Thu, 29 May 2025 08:42:57 +0000 (+1000) Subject: Panic if renaming from and to same file X-Git-Tag: v1.59.0~94 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=d6a317aac01645e7dc8d11fe690526effe4c6d12;p=btrtrc.git Panic if renaming from and to same file --- diff --git a/storage/file-piece.go b/storage/file-piece.go index fe8cd6ba..d52e7035 100644 --- a/storage/file-piece.go +++ b/storage/file-piece.go @@ -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) {