Clean issues about removed items on scanner startup

This commit is contained in:
Zoe Roux 2024-05-02 00:51:56 +02:00
parent 57842ea31c
commit 6925c6b225
No known key found for this signature in database
2 changed files with 15 additions and 0 deletions

View File

@ -58,6 +58,16 @@ class KyooClient:
logger.error(f"Request error: {await r.text()}") logger.error(f"Request error: {await r.text()}")
r.raise_for_status() r.raise_for_status()
async def get_issues(self) -> List[str]:
async with self.client.get(
f"{self._url}/issues",
params={"limit": 0},
headers={"X-API-Key": self._api_key},
) as r:
r.raise_for_status()
ret = await r.json()
return [x["cause"] for x in ret if x["domain"] == "scanner"]
async def delete_issue(self, path: str): async def delete_issue(self, path: str):
async with self.client.delete( async with self.client.delete(
f'{self._url}/issues?filter=domain eq scanner and cause eq "{quote(path)}"', f'{self._url}/issues?filter=domain eq scanner and cause eq "{quote(path)}"',

View File

@ -35,5 +35,10 @@ async def scan(
elif len(deleted) > 0: elif len(deleted) > 0:
logger.warning("All video files are unavailable. Check your disks.") logger.warning("All video files are unavailable. Check your disks.")
issues = await client.get_issues()
for x in issues:
if x not in videos:
await client.delete_issue(x)
await asyncio.gather(*map(publisher.add, to_register)) await asyncio.gather(*map(publisher.add, to_register))
logger.info(f"Scan finished for {path}.") logger.info(f"Scan finished for {path}.")