daemon: Correctly handle EMLINK corner case when deduplicating.
Suggested by Caleb Ristvedt <caleb.ristvedt@cune.org>. * nix/libstore/optimise-store.cc (LocalStore::optimisePath_): Save errno from 'rename' before calling 'unlink'.
This commit is contained in:
parent
b06ba9e0ff
commit
b930f0ba21
@ -215,9 +215,10 @@ void LocalStore::optimisePath_(OptimiseStats & stats, const Path & path, InodeHa
|
|||||||
|
|
||||||
/* Atomically replace the old file with the new hard link. */
|
/* Atomically replace the old file with the new hard link. */
|
||||||
if (rename(tempLink.c_str(), path.c_str()) == -1) {
|
if (rename(tempLink.c_str(), path.c_str()) == -1) {
|
||||||
|
int renameErrno = errno;
|
||||||
if (unlink(tempLink.c_str()) == -1)
|
if (unlink(tempLink.c_str()) == -1)
|
||||||
printMsg(lvlError, format("unable to unlink `%1%'") % tempLink);
|
printMsg(lvlError, format("unable to unlink `%1%'") % tempLink);
|
||||||
if (errno == EMLINK) {
|
if (renameErrno == EMLINK) {
|
||||||
/* Some filesystems generate too many links on the rename,
|
/* Some filesystems generate too many links on the rename,
|
||||||
rather than on the original link. (Probably it
|
rather than on the original link. (Probably it
|
||||||
temporarily increases the st_nlink field before
|
temporarily increases the st_nlink field before
|
||||||
|
Loading…
Reference in New Issue
Block a user