Skip to content

Commit

Permalink
Merge pull request NixOS#12103 from CertainLach/fsync-store-paths-sym…
Browse files Browse the repository at this point in the history
…links

fix: ignore symlinks in fsync-store-paths
  • Loading branch information
mergify[bot] authored Dec 25, 2024
2 parents f72752c + 4a91e62 commit bff9296
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/libutil/file-system.cc
Original file line number Diff line number Diff line change
Expand Up @@ -331,15 +331,16 @@ 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));
if (!fd)
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. */
Expand Down

0 comments on commit bff9296

Please sign in to comment.