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
Extend last_write_time
implementation by special-casing file touching
#2141
Extend last_write_time
implementation by special-casing file touching
#2141
Conversation
@wolfv Do I need to ping someone for review? I am pretty confident this solves the The gist is that on linux only the owner is allowed to update the modification time of a file to a particular timestamp, while it is permitted for everyone with write access to update the modification time to the current time, but the |
last_write_time
implementation by special-casing file touching
Updated the PR description to make it easier to follow and hope to find someone for review! |
…rt ACL's Co-authored-by: Bourdon Olivier <mail@olivier-bourdon.fr>
db76640
to
962a7e6
Compare
Thanks, I looked through the PR and it looks good to me! Will ask @Klaim what he thinks, then happy to merge! :) Do you know if this also works on macOS? |
Judging by this issue on some other repo, it seems that the command was not available before macOS 10.12: bytecodealliance/rustix#157 |
Thanks for the PR! I just started reviewing this., other than informing myself of the details, As the proposed function is an extension of the standard interface we try to keep, the overall idea of this PR seems reasonable to me. Could the (I didn´t look at the ci issues yet) |
Great to see this is moving somewhere.
I am not married to the name, if you find a more fitting alternative i'm happy to oblige.
There was no report about a multi-user issue on MacOS X, which given the nature of normal mac usage is not surprising, but i can actually try on my machine. Will report back. On systems for which |
Thanks for the details @coroa I was looking at libcxx (from llvm) and libstdc++ (from gcc) and they actually do use See:
Therefore, if my understanding is correct (I probably missed something), the issue is really that our calls to I cannot yet reproduce the initial issue, but if you do reproduce it, could you check if using only that implementation https://github.com/mamba-org/mamba/pull/2141/files#diff-14842e873613261b88cfd612f98b39a7ded38892a8465daa346d2b3ee62891f4R1165-R1166 for that new function actually fixes the issue? |
Looks like the CI issues are unrelated to this PR? |
yep, i think most of the ci issues are unrelated :) |
No, you are slightly off course.
(as described in the manpage utimensat ) |
I unfortunately CAN reproduce the issue on MacOS 12.6. |
Note also that this is equivalent to the current implementation which exhibits the issue, since mamba/libmamba/src/core/subdirdata.cpp Line 462 in 01f6018
mamba/libmamba/src/core/subdirdata.cpp Line 512 in 01f6018
|
I found that llvm's libcxx implementation uses the presence of the I would propose to make the new code conditional on this constant being defined, then we fall back to the old implementation when |
That makes sense to me indeed. If that fixes also the macos build, then after fixing the ci I'm ok to merge this change 👍🏽 Thanks for the detailed explaination. |
// We can use the presence of UTIME_OMIT to detect platforms that provide | ||
// utimensat. | ||
#if defined(UTIME_OMIT) | ||
#define USE_UTIMENSAT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering whether to prefix the constant, ie like _MAMBA_USE_UTIMENSAT
?
Ok, with this change it compiles and fixes the issue on ubuntu and MacOSX. Tests on MacOSX pass, on ubuntu i'm seeing some file locking errors, which i don't think are related to the filesystem layer. (Merry christmas!) |
Thanks so much! I hope you had some wonderful holidays :) |
Continuation of #1137 .
Fixes #1123 .
Only the owner (or a priviledged user) is allowed to set file modification time to a specific timestamp, as documented at the manpage for
utimensat
. Therefore, callinglast_write_time
on the cache file fails with aRuntimeError: Operation not permitted
exception.But for anyone with write access to the file it is permitted to update the timestamp to the current time by passing a
NULL
-pointer or aUTIME_NOW
special constant.This special case of calling
utimensat
is not exposed by thestd::filesystem::last_write_time
layer. This PR adds a similarstd:filesystem::now
sentinel value to thelast_write_time
interface, which callsutimensat
with theNULL
pointer on supported systems and forwards the call to the original implementation on windows.Fixes the test case described in #1123 (comment) :
File modification times are updated as well: