Skip to content

Commit fe19246

Browse files
committed
Handle EEXIST for Linux rename failure
Documentation says it can either be ENOTEMPTY (like Darwin) or EEXIST. Also print the error. (cherry picked from commit bb52d96)
1 parent 71f0197 commit fe19246

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

llvm/lib/CAS/UnifiedOnDiskCache.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,8 @@ UnifiedOnDiskCache::validateIfNeeded(StringRef RootPath, StringRef HashName,
442442
sys::path::append(GCPath, CorruptPrefix + std::to_string(Attempt) +
443443
"." + DBDir);
444444
EC = sys::fs::rename(PathBuf, GCPath);
445-
if (EC != errc::directory_not_empty)
445+
// Darwin uses ENOTEMPTY. Linux may return either ENOTEMPTY or EEXIST.
446+
if (EC != errc::directory_not_empty && EC != errc::file_exists)
446447
break;
447448
}
448449
if (Attempt == MaxAttempts)
@@ -451,7 +452,7 @@ UnifiedOnDiskCache::validateIfNeeded(StringRef RootPath, StringRef HashName,
451452
" failed: too many CAS directories awaiting pruning");
452453
if (EC)
453454
return createStringError(EC, "rename " + PathBuf + " to " + GCPath +
454-
" failed");
455+
" failed: " + EC.message());
455456
}
456457
Recovered = true;
457458
}

0 commit comments

Comments
 (0)