mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 12:08:36 +00:00
instance_lists: treat case-only report paths as one file.
On a case-insensitive volume, normcase left two spellings of a report that has not been created as two paths. The shared report-path check folds that case. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -255,6 +255,22 @@ class ArchiveTests(unittest.TestCase):
|
||||
with open(path, "rb") as fh:
|
||||
self.assertEqual(fh.read(), data)
|
||||
|
||||
def test_case_only_spelling_of_a_missing_report_is_one_path(self):
|
||||
# normcase keeps case on macOS, and samefile cannot see a file that has not been created.
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
folder = os.path.join(tmp, "Reports")
|
||||
os.mkdir(folder)
|
||||
probe = os.path.join(folder, "Probe.tmp")
|
||||
with open(probe, "wb"):
|
||||
pass
|
||||
insensitive = os.path.exists(os.path.join(folder, "probe.tmp"))
|
||||
os.remove(probe)
|
||||
if not insensitive:
|
||||
self.skipTest("volume keeps case")
|
||||
first = os.path.join(tmp, "Reports", "out.json")
|
||||
second = os.path.join(tmp, "reports", "out.json")
|
||||
self.assertTrue(il.same_output_path(first, second))
|
||||
|
||||
def test_json_that_is_a_directory_is_refused_before_the_scan(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
path, _ = self._archive(tmp)
|
||||
|
||||
@ -37,6 +37,9 @@ import zlib
|
||||
|
||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||
import world_index as wi # noqa: E402 (same 0x7a header, schema and stream helpers)
|
||||
from report_paths import same_report_path # noqa: E402
|
||||
|
||||
same_output_path = same_report_path
|
||||
|
||||
PROP_LIST, PROP_INST = 0xBA049770, 0xEA6B3A96
|
||||
GRASS_LIST, GRASS_INST = 0x7C475B5D, 0xED86F522
|
||||
@ -327,15 +330,6 @@ def scan(path, T, start=None, limit=None):
|
||||
pos = s + max(used, 1)
|
||||
|
||||
|
||||
def same_output_path(first, second):
|
||||
if os.path.normcase(os.path.realpath(first)) == os.path.normcase(os.path.realpath(second)):
|
||||
return True
|
||||
try:
|
||||
return os.path.samefile(first, second)
|
||||
except OSError:
|
||||
return False
|
||||
|
||||
|
||||
def _int_arg(text):
|
||||
try:
|
||||
return int(text, 0)
|
||||
|
||||
Reference in New Issue
Block a user