Skip to content

Input: Replace markFileChanged() by putFile()#9239

Merged
edolstra merged 3 commits intoNixOS:masterfrom
edolstra:putFile
Oct 31, 2023
Merged

Input: Replace markFileChanged() by putFile()#9239
edolstra merged 3 commits intoNixOS:masterfrom
edolstra:putFile

Conversation

@edolstra
Copy link
Copy Markdown
Member

Motivation

Committing a lock file using markFileChanged() required the input to be writable by the caller in the local filesystem (using the path returned by getSourcePath()). putFile() abstracts over this.

Extracted from lazy-trees (which removes getSourcePath() entirely).

Context

Priorities

Add 👍 to pull requests you find important.

@github-actions github-actions bot added the fetching Networking with the outside (non-Nix) world, input locking label Oct 25, 2023
Committing a lock file using markFileChanged() required the input to
be writable by the caller in the local filesystem (using the path
returned by getSourcePath()). putFile() abstracts over this.
@edolstra edolstra mentioned this pull request Oct 25, 2023
Copy link
Copy Markdown
Member

@Ericson2314 Ericson2314 left a comment

Choose a reason for hiding this comment

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

The rest looks good to me :)

auto outputLockFilePath = sourcePath ? std::optional{*sourcePath + "/" + relPath} : std::nullopt;

newLockFile.write(*outputLockFilePath);
bool lockFileExists = pathExists(*outputLockFilePath);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This will crash if the previous line set std::nullopt right?

looking further up I think that is impossible because the new if (sourcePath || lockFlags.outputLockFilePath) and then lockFlags.outputLockFilePath right? but in that case we should assert(sourcePath); in this branch and then get rid of the sourcePath ? ....

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks, I've cleaned this up.

@edolstra edolstra merged commit fa6bc33 into NixOS:master Oct 31, 2023
@edolstra edolstra deleted the putFile branch October 31, 2023 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fetching Networking with the outside (non-Nix) world, input locking

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants