From b08e14bbcf1b30c5266d89f6fdcc3a6cfa0324fa Mon Sep 17 00:00:00 2001
From: zeripath <art27@cantab.net>
Date: Fri, 16 Jul 2021 18:16:04 +0100
Subject: [PATCH] Retry rename on lock induced failures (re-fix) (#16461)

Unfortunately #16435 asserts the wrong error and should use
os.LinkError not os.PathError.

Fix #16439

Signed-off-by: Andrew Thornton <art27@cantab.net>
---
 modules/util/remove.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/modules/util/remove.go b/modules/util/remove.go
index 2310436525..754f3b7c11 100644
--- a/modules/util/remove.go
+++ b/modules/util/remove.go
@@ -64,7 +64,7 @@ func Rename(oldpath, newpath string) error {
 		if err == nil {
 			break
 		}
-		unwrapped := err.(*os.PathError).Err
+		unwrapped := err.(*os.LinkError).Err
 		if unwrapped == syscall.EBUSY || unwrapped == syscall.ENOTEMPTY || unwrapped == syscall.EPERM || unwrapped == syscall.EMFILE || unwrapped == syscall.ENFILE {
 			// try again
 			<-time.After(100 * time.Millisecond)