Skip to content

Commit

Permalink
added test case..
Browse files Browse the repository at this point in the history
Change-Id: Iea39f1637a5f42304622bbb9a6d831b2568c16ac
  • Loading branch information
rmittal87 committed Sep 25, 2023
1 parent 3a88dac commit 8f70359
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 27 deletions.
3 changes: 0 additions & 3 deletions libmamba/include/mamba/core/util_os.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ namespace mamba
void codesign(const fs::u8path& path, bool verbose = false);

std::string fix_win_path(const std::string& path);
#ifndef _WIN32
bool is_executable(const fs::u8path& path);
#endif
}

#endif
16 changes: 11 additions & 5 deletions libmamba/src/core/link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -753,8 +753,7 @@ namespace mamba
{
bool copy = path_data.no_link || m_context->always_copy;
bool softlink = m_context->always_softlink;

if ((!copy && !softlink) || is_executable(src))
if (!copy && !softlink)
{
std::error_code lec;
fs::create_hard_link(src, dst, lec);
Expand Down Expand Up @@ -789,15 +788,22 @@ namespace mamba
try
{
fs::copy(src, dst);
LOG_TRACE << "copied '" << src.string() << "'" << std::endl
<< " --> '" << dst.string() << "'";
}
catch (const std::filesystem::filesystem_error& ex)
{
Console::stream() << "could not copy: " << src.string() << " -> "
<< dst.string() << ": " << ex.what();
if (fs::exists(dst))
{
LOG_TRACE << dst.string() << " already exists" << std::endl;
}
else
{
throw ex;
}
}

LOG_TRACE << "copied '" << src.string() << "'" << std::endl
<< " --> '" << dst.string() << "'";
}
}
else if (path_data.path_type == PathType::SOFTLINK)
Expand Down
19 changes: 0 additions & 19 deletions libmamba/src/core/util_os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -705,23 +705,4 @@ namespace mamba
return path;
#endif
}

#ifndef _WIN32
bool is_executable(const fs::u8path& path)
{
struct stat sb;
bool rc = false;
if (stat(path.string().c_str(), &sb) != 0)
{
return rc;
}

if (sb.st_mode & S_IXUSR)
{
rc = true;
}
return rc;
}
#endif

}
2 changes: 2 additions & 0 deletions micromamba/tests/test_linking.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def test_copy(self, existing_cache, test_pkg):
def test_always_softlink(self, existing_cache, test_pkg):
create(
"xtensor",
"r-base",
"-n",
TestLinking.env_name,
"--json",
Expand All @@ -101,6 +102,7 @@ def test_cross_device(self, allow_softlinks, always_copy, existing_cache, test_p
pytest.skip("o/s is not linux")

create_args = ["xtensor", "-n", TestLinking.env_name, "--json"]

if allow_softlinks:
create_args.append("--allow-softlinks")
if always_copy:
Expand Down

0 comments on commit 8f70359

Please sign in to comment.