fix(connect): queue new files with the audiobookshelf watcher instead of a full scan

This commit is contained in:
Steppenstreuner committed 2026-10-27 06:44:38 +01:00
1 parent 173e24a362
commit 377d2c8557
2 files changed
+52 -12

No files matched your search

+22 -7
View File
@@ -1,4 +1,5 @@
import importlib
import json
import os
import shutil
from pathlib import Path
@@ -1228,12 +1229,13 @@ def test_connections_hear_about_committed_rows(client, monkeypatch):
from wordarr import connect
calls = []
watcher = {"disableWatcher": False}
def handler(request):
calls.append((request.method, str(request.url)))
calls.append((request.method, str(request.url), request.content))
if request.url.path == "/api/libraries":
return httpx.Response(200, json={"libraries": [
{"id": "lib-audio", "name": "Audio",
{"id": "lib-audio", "name": "Audio", "settings": watcher,
"folders": [{"fullPath": str(client.tmp_path / "library")}]},
{"id": "lib-pod", "name": "Pod", "folders": [{"fullPath": "/podcasts"}]},
]})
@@ -1261,16 +1263,29 @@ def test_connections_hear_about_committed_rows(client, monkeypatch):
"path": str(src), "is_dir": False, "files": [str(src)], "request_id": req_id,
}]}).json()["results"][0]["ok"]
assert calls == [
# no full scan while the watcher runs: the two raced and added the book twice
dest = str(root / "Momo" / "Momo.epub")
assert [c[:2] for c in calls] == [
("POST", "http://hook/in"),
("GET", "http://abs/api/libraries"),
("POST", "http://abs/api/watcher/update"),
]
assert json.loads(calls[2][2]) == {
"libraryId": "lib-audio", "path": dest, "type": "add"}
calls.clear()
client.delete(f"/api/requests/{req_id}")
assert [c[:2] for c in calls] == [("POST", "http://hook/in")] # nothing new on disk
calls.clear()
watcher["disableWatcher"] = True
connect.notify([{"event": "imported", "dest": dest}])
assert [c[:2] for c in calls] == [
("POST", "http://hook/in"),
("GET", "http://abs/api/libraries"),
("POST", "http://abs/api/libraries/lib-audio/scan"),
]
calls.clear()
client.delete(f"/api/requests/{req_id}")
assert calls == [("POST", "http://hook/in")] # nothing new on disk, no scan
def test_bulk_move_delete_and_count(client):
def lib(name, media_type):