Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inline the usage of nix::renameFile, nix::getFileType and nix::copyFile #10685

Merged
merged 4 commits into from May 13, 2024

Conversation

siddhantk232
Copy link
Contributor

Motivation

In order to reduce the footprint of our filesystem API, we're trying to remove existing functions with direct calls to std::filesystem functions.

Context

#9205

Priorities and Process

Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

use `std::filesystem::rename` everywhere and remove `nix::renameFile`
the old `copyFile` was just a wrapper that was calling the `copy`
function. This wrapper function is removed and the `copy` function is
renamed to `copyFile`.
@github-actions github-actions bot added the store Issues and pull requests concerning the Nix store label May 12, 2024
@nicepc

This comment was marked as off-topic.

@@ -194,7 +190,7 @@ void moveFile(const Path & src, const Path & dst);
* with the guaranty that the destination will be “fresh”, with no stale inode
* or file descriptor pointing to it).
*/
void copyFile(const Path & oldPath, const Path & newPath, bool andDelete);
void copyFile(const std::filesystem::directory_entry & from, const std::filesystem::path & to, bool andDelete);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is from a directory_entry rather than a path?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed it to use path instead in 62e1ea2. Not sure why it was directory_entry before.

@edolstra edolstra merged commit 56abd34 into NixOS:master May 13, 2024
9 checks passed
@@ -611,55 +605,45 @@ static void setWriteTime(const fs::path & p, const struct stat & st)
}
#endif

void copy(const fs::directory_entry & from, const fs::path & to, bool andDelete)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we might still want a copyEntry function as an implementation detail because it can avoid another stat in many cases (because the directory listing already has the info).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
store Issues and pull requests concerning the Nix store
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants