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

Make files writable when they are exported. #149

Merged
merged 3 commits into from
Jul 8, 2024
Merged

Conversation

plietar
Copy link
Member

@plietar plietar commented Jul 2, 2024

Since orderly2#141, orderly marks all files in the archive as read-only. Similarly, files in the file store have always been read-only. This helps prevent accidental corruption by users.

However this has had the undesirable side-effect of copying the files with the read-only bit set, even when exporting for interactive use by the user.

One scenario where this has come up is a user running orderly_dependency interactively twice. They would expect the second call to succeed and overwrite the existing files. However this was not the case, and instead the second call fails as the read-only files cannot be overwritten. The user ends up having to manually delete these files (or mark them writable) everytime they want to update their copy.

This change marks all files that are exported as writable. This does not apply to calls to orderly_dependency from a job context, in which case the files are still read-only.

@plietar plietar requested a review from richfitz July 2, 2024 16:51
Copy link
Member

@richfitz richfitz left a comment

Choose a reason for hiding this comment

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

one suggestion of a test, but it's probably ok (and infact is quite possibly somewhere). Can you bump the version please so that we don't get two different versions with the same number in the wild? I have an action somewhere to enforce this we might use

@@ -157,3 +157,33 @@ test_that("good error message if file not found in packet", {
i = "For 'd.txt' did you mean 'a.txt', 'b.txt' or 'c.txt'",
i = "Remember that all orderly paths are case sensitive"))
})


test_that("Can overwrite when copying files from packet", {
Copy link
Member

Choose a reason for hiding this comment

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

can you add a test to verify that orderly_dependency is still copying files over read-only within a packet run? It's not immediately obvious to me from the implementation change that this will the the case. TBH I've entirely forgotten how the various bits of file exporting play together so it would be good to prevent any regression if we change the implementation

Copy link
Member

Choose a reason for hiding this comment

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

ok, looks like this is due to

  outpack_packet_file_mark(packet, result$files$here, "immutable")

in the active context, so that's nice

Copy link
Member Author

@plietar plietar Jul 8, 2024

Choose a reason for hiding this comment

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

file_mark only adds a check the file's hash at the end of the packet run, it doesn't pro-actively prevent files from being modified (albeit the result is basically the same I suppose).

file_export, which I've modified here, does not get called by the orderly_run flow. I'll add a test still.

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope, I was wrong about that file_export not being called. With this PR, files in the draft folder become mutable again (as they were before #141).

The outpack_packet_file_mark still does it's job of checking at the end of the packet, so in my opinion that's fine. I've added an explicit test for this.

plietar added 3 commits July 8, 2024 13:35
Since [orderly2#141], orderly marks all files in the archive as
read-only. Similarly, files in the file store have always been
read-only. This helps prevent accidental corruption by users.

However this has had the undesirable side-effect of copying the files
with the read-only bit set, even when exporting for interactive use by
the user.

One scenario where this has come up is a user running
`orderly_dependency` interactively twice. They would expect the second
call to succeed and overwrite the existing files. However this was not
the case, and instead the second call fails as the read-only files
cannot be overwritten. The user ends up having to manually delete these
files (or mark them writable) everytime they want to update their copy.

This change marks all files that are exported as writable. This does not
apply to calls to `orderly_dependency` from a job context, in which case
the files are still read-only.

[orderly2#141]: #141
@plietar plietar force-pushed the mrc-5495-writable branch from 7cb1d5b to d872996 Compare July 8, 2024 12:53
@plietar plietar requested a review from richfitz July 8, 2024 12:55
@richfitz richfitz merged commit 195ffc5 into main Jul 8, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants