mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-21 09:07:50 -06:00
fix: a lock reader refuses a missing directory
artifact_lock created its directory even for a shared reader, so a mistyped path given to --verify-packs or release_record was left as a directory holding a .lock, and split_pack created the parent before printing a bare errno. A reader now raises ArtifactDirectoryMissing, which run_cli prints on one line, and split_pack checks its target before taking the lock.
This commit is contained in:
1 parent
19dddedff6
commit
a1ddee8e5e
4 files changed
+40
-1
No files matched your search
@@ -61,6 +61,28 @@ class ArtifactLockTest(unittest.TestCase):
|
||||
with artifact_lock(self.dir, exclusive=False):
|
||||
pass
|
||||
|
||||
def test_a_reader_never_creates_the_directory(self):
|
||||
"""A mistyped --output-dir given to --verify-packs or release_record
|
||||
was created holding a .lock, and the next run with the same typo no
|
||||
longer said the path did not exist."""
|
||||
from common import ArtifactDirectoryMissing # noqa: PLC0415
|
||||
|
||||
missing = os.path.join(self.dir, "sub", "dsit")
|
||||
with self.assertRaises(ArtifactDirectoryMissing):
|
||||
with artifact_lock(missing, exclusive=False):
|
||||
pass
|
||||
self.assertFalse(os.path.exists(os.path.join(self.dir, "sub")))
|
||||
|
||||
def test_split_refuses_a_missing_target_before_locking(self):
|
||||
missing = Path(self.dir) / "sub" / "dsit"
|
||||
proc = subprocess.run(
|
||||
[sys.executable, "scripts/split_pack.py", str(missing)],
|
||||
cwd=REPO_ROOT, capture_output=True, text=True, check=False, timeout=60,
|
||||
)
|
||||
self.assertEqual(proc.returncode, 1)
|
||||
self.assertIn("no such pack or directory", proc.stderr)
|
||||
self.assertFalse(missing.parent.exists())
|
||||
|
||||
def test_lock_is_released_on_exit(self):
|
||||
with artifact_lock(self.dir):
|
||||
pass
|
||||
|
||||
Reference in new issue
Block a user