Fix locking error (#3572)

This commit is contained in:
Hind-M 2024-10-30 14:50:16 +01:00 committed by GitHub
parent b94b30e941
commit 94bb087acb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 2 deletions

View File

@ -207,7 +207,7 @@ namespace mamba
return;
}
// Run `pip freeze`
// Run `pip inspect`
std::string out, err;
const auto get_python_path = [&]

View File

@ -722,9 +722,18 @@ namespace mamba
, m_locked(false)
{
std::error_code ec;
// Check if `path` exists
if (!fs::exists(path, ec))
{
throw_lock_error(fmt::format("Could not lock non-existing path '{}'", path.string()));
// If `path` doesn't exist, consider creating the directory
// (and its parents if they don't exist)
if (!fs::create_directories(path, ec))
{
throw_lock_error(
fmt::format("Could not create directory '{}': {}", path.string(), ec.message())
);
}
}
if (fs::is_directory(path))