Skip to content

Conversation

@pkrog
Copy link

@pkrog pkrog commented Nov 27, 2025

Description

When trying to set execution mode for a file or setting permissions to cache directory, an error may occur if we have no modification right on the parent folder.
This error occurs regardless of the current permissions on the targeted file or folder.
Thus, even if we already have the required permissions on the targeted file or folder, the error occurs.

This pull request introduces a function has_permissions() that tests if we already have the wanted permissions on a file or folder.
This new function is used at the two places described above, in order to avoid a useless setting of permissions that would lead to an error.

Type of Change

  • Bugfix
  • Feature / enhancement
  • CI / Documentation
  • Maintenance

Checklist

  • My code follows the general style and conventions of the codebase, ensuring consistency
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have run pre-commit run --all locally in the source folder and confirmed that there are no linter errors.
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing tests pass locally with my changes

@github-actions github-actions bot added the release::bug_fixes For PRs fixing bugs label Nov 27, 2025
@codecov
Copy link

codecov bot commented Nov 27, 2025

Codecov Report

❌ Patch coverage is 97.14286% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.63%. Comparing base (c641811) to head (ad237ab).

Files with missing lines Patch % Lines
libmamba/src/core/subdir_index.cpp 84.61% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4107      +/-   ##
==========================================
+ Coverage   63.58%   63.63%   +0.05%     
==========================================
  Files         315      315              
  Lines       38562    38621      +59     
  Branches     2950     2954       +4     
==========================================
+ Hits        24518    24578      +60     
+ Misses      13975    13974       -1     
  Partials       69       69              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@pkrog
Copy link
Author

pkrog commented Nov 27, 2025

Codecov Report

❌ Patch coverage is 97.14286% with 2 lines in your changes missing coverage. Please review. ✅ Project coverage is 63.63%. Comparing base (c641811) to head (ad237ab).
Files with missing lines Patch % Lines
libmamba/src/core/subdir_index.cpp 84.61% 2 Missing ⚠️
Additional details and impacted files

☔ View full report in Codecov by Sentry. 📢 Have feedback on the report? Share it here.
🚀 New features to boost your workflow:

Note that I am not responsible for the two lines in question. They were here before, thus already not tested.

@jjerphan jjerphan changed the title Solve bug when changing permissions with no modification right fix: Solve bug when changing permissions with no modification right Nov 28, 2025
Copy link
Member

@Klaim Klaim left a comment

Choose a reason for hiding this comment

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

LGTM in essence but I would need a bit more documentation of the function.

As for the CI error on Windows, I'm not totally sure but I suspect the specific check is about a kind of permission not supported by that OS? Not sure.

return std::filesystem::last_write_time(path, new_time, std::forward<OtherArgs>(args)...);
}

// Check if we have modification rights on a path
Copy link
Member

Choose a reason for hiding this comment

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

Could you add:

  • a clarification that this function is not part of std::filesystem (mamba::fs namespace reflects std::filesystem, see the comment at the top of the file for why);
  • clarifications on the preconditions, in particular what happens if the provided path doesnt lead to a file or directory;


#ifndef _WIN32
#include <fcntl.h>
#include <grp.h>
Copy link
Member

Choose a reason for hiding this comment

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

Why are these headers required if you're using only the C++ standard library api?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release::bug_fixes For PRs fixing bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants