From d6a317aac01645e7dc8d11fe690526effe4c6d12 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Thu, 29 May 2025 18:42:57 +1000 Subject: [PATCH] Panic if renaming from and to same file --- storage/file-piece.go | 1 + 1 file changed, 1 insertion(+) 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) { -- 2.51.0