fix(audiocpp): replace stale model aliases
This commit is contained in:
@@ -226,14 +226,24 @@ def _materialize_gguf_cache_path(model_file: Path) -> Path:
|
||||
raise RuntimeError(f"audio.cpp model must be a .gguf file: {model_file}")
|
||||
|
||||
def _link(alias: Path) -> Path:
|
||||
try:
|
||||
os.link(resolved, alias)
|
||||
except FileExistsError:
|
||||
if not os.path.samefile(resolved, alias):
|
||||
for attempt in range(2):
|
||||
try:
|
||||
os.link(resolved, alias)
|
||||
except FileExistsError:
|
||||
if (
|
||||
not alias.is_symlink()
|
||||
and alias.is_file()
|
||||
and os.path.samefile(resolved, alias)
|
||||
):
|
||||
return alias
|
||||
if attempt == 0 and alias.is_symlink():
|
||||
alias.unlink()
|
||||
continue
|
||||
raise RuntimeError(
|
||||
f"audio.cpp model alias points at a different file: {alias}"
|
||||
) from None
|
||||
return alias
|
||||
return alias
|
||||
raise RuntimeError(f"audio.cpp model alias could not be created: {alias}")
|
||||
|
||||
alias = model_file.with_name(
|
||||
f".{model_file.stem}-{HF_MODEL_REVISION[:12]}.audiocpp.gguf"
|
||||
|
||||
@@ -39,14 +39,15 @@ function okResponse(rec: LastRunCrashRecord | null, acknowledged = false) {
|
||||
|
||||
describe('_adaptLastRunCrash — run-sentinel record → CrashMarker shape', () => {
|
||||
it('maps the record so the existing crash UI can render it', () => {
|
||||
const marker = _adaptLastRunCrash(record(), false);
|
||||
const sourceRecord = record();
|
||||
const marker = _adaptLastRunCrash(sourceRecord, false);
|
||||
expect(marker.exit_code).toBeNull();
|
||||
expect(marker.signal).toBeNull();
|
||||
// describeCrashExit falls through to exit_desc on a null code+signal.
|
||||
expect(describeCrashExit(marker)).toBe('process ended uncleanly (previous run)');
|
||||
expect(marker.backend_version).toBe('0.3.23');
|
||||
expect(marker.uptime_s).toBe(510);
|
||||
expect(marker.ts).toBe(record().detected_at);
|
||||
expect(marker.ts).toBe(sourceRecord.detected_at);
|
||||
expect(marker.acknowledged).toBe(false);
|
||||
// The "stderr" evidence carries the last activity + the scrubbed log tail.
|
||||
expect(marker.last_stderr).toContain('last activity before the death: transcribe (dub)');
|
||||
|
||||
@@ -212,6 +212,24 @@ def test_materialize_rejects_extensionless_model(tmp_path, app_modules):
|
||||
bootstrap._materialize_gguf_cache_path(model)
|
||||
|
||||
|
||||
def test_materialize_replaces_preexisting_symlink_alias(tmp_path, app_modules):
|
||||
bootstrap = app_modules.bootstrap
|
||||
blob = tmp_path / "content-addressed-blob"
|
||||
blob.write_bytes(b"GGUF test payload")
|
||||
snapshot = tmp_path / "breeze-tts-2-q8_0.gguf"
|
||||
snapshot.symlink_to(blob)
|
||||
alias = snapshot.with_name(
|
||||
f".{snapshot.stem}-{bootstrap.HF_MODEL_REVISION[:12]}.audiocpp.gguf"
|
||||
)
|
||||
alias.symlink_to(blob)
|
||||
|
||||
materialized = bootstrap._materialize_gguf_cache_path(snapshot)
|
||||
|
||||
assert materialized == alias
|
||||
assert not materialized.is_symlink()
|
||||
assert os.path.samefile(materialized, blob)
|
||||
|
||||
|
||||
def test_materialize_cross_filesystem_symlink_links_beside_target(
|
||||
tmp_path, monkeypatch, app_modules,
|
||||
):
|
||||
@@ -240,6 +258,7 @@ def test_materialize_cross_filesystem_symlink_links_beside_target(
|
||||
|
||||
assert materialized.parent == blob.parent
|
||||
assert materialized.suffix == ".gguf"
|
||||
assert not materialized.is_symlink()
|
||||
assert os.path.samefile(materialized, blob)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user