Skip to content

Commit

Permalink
Better samefile detection
Browse files Browse the repository at this point in the history
  • Loading branch information
kenodegard committed Nov 6, 2023
1 parent bbaadc1 commit 85ba9c2
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions conda_build/inspect_pkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,20 @@ def which_package(
only one package.
"""
prefix = Path(prefix)
# historically, path was relative to prefix just to be safe we append to prefix
# (pathlib correctly handles this even if path is absolute)
path = prefix / path

def samefile(path1: Path, path2: Path) -> bool:
try:
return path1.samefile(path2)
except FileNotFoundError:
# FileNotFoundError: path doesn't exist
return path1 == path2

for prec in PrefixData(str(prefix)).iter_records():
for file in prec["files"]:
# historically, path was relative to prefix just to be safe we append to prefix
# (pathlib correctly handles this even if path is absolute)
if (prefix / file).samefile(prefix / path):
if samefile(prefix / file, path):
yield prec


Expand Down

0 comments on commit 85ba9c2

Please sign in to comment.