From 4a91e627a7617cc3d654967358fd29df076ab853 Mon Sep 17 00:00:00 2001 From: Yaroslav Bolyukin Date: Wed, 25 Dec 2024 02:41:20 +0100 Subject: [PATCH] fix: ignore symlinks in fsync-store-paths Fixes: https://github.com/NixOS/nix/issues/12099 --- src/libutil/file-system.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libutil/file-system.cc b/src/libutil/file-system.cc index 50e90bb57..793eb2d9f 100644 --- a/src/libutil/file-system.cc +++ b/src/libutil/file-system.cc @@ -331,7 +331,7 @@ void syncParent(const Path & path) void recursiveSync(const Path & path) { - /* If it's a file, just fsync and return. */ + /* If it's a file or symlink, just fsync and return. */ auto st = lstat(path); if (S_ISREG(st.st_mode)) { AutoCloseFD fd = toDescriptor(open(path.c_str(), O_RDONLY, 0)); @@ -339,7 +339,8 @@ void recursiveSync(const Path & path) throw SysError("opening file '%1%'", path); fd.fsync(); return; - } + } else if (S_ISLNK(st.st_mode)) + return; /* Otherwise, perform a depth-first traversal of the directory and fsync all the files. */