fix: handle non-files in check_modified/uninstall, validate manifest key

- check_modified() treats non-regular-files (dirs, symlinks) as modified
  instead of crashing with IsADirectoryError
- uninstall() skips directories (adds to skipped list), only unlinks
  files and symlinks
- load() validates stored integration key matches the requested key
This commit is contained in:
Manfred Riem
2026-03-31 09:48:06 -05:00
parent a2f03ceacf
commit a84598617f

View File

@@ -119,6 +119,10 @@ class IntegrationManifest:
continue
if not abs_path.exists():
continue
# Treat non-regular-files (directories, symlinks) as modified
if not abs_path.is_file():
modified.append(rel)
continue
if _sha256(abs_path) != expected_hash:
modified.append(rel)
return modified
@@ -157,6 +161,10 @@ class IntegrationManifest:
continue
if not path.exists():
continue
# Skip directories — manifest only tracks files
if not path.is_file() and not path.is_symlink():
skipped.append(path)
continue
if not force and _sha256(path) != expected_hash:
skipped.append(path)
continue
@@ -234,4 +242,12 @@ class IntegrationManifest:
inst.version = data.get("version", "")
inst._installed_at = data.get("installed_at", "")
inst._files = files
stored_key = data.get("integration", "")
if stored_key and stored_key != key:
raise ValueError(
f"Manifest at {path} belongs to integration {stored_key!r}, "
f"not {key!r}"
)
return inst