mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Clean issues about removed items on scanner startup
This commit is contained in:
parent
57842ea31c
commit
6925c6b225
@ -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)}"',
|
||||||
|
@ -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}.")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user