Skip to content

Commit

Permalink
fix(mirroring): backport problem of not mirroring (#300)
Browse files Browse the repository at this point in the history
  • Loading branch information
SaidBySolo authored Oct 16, 2022
1 parent 0b23460 commit 1e74460
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions heliotrope/tasks/mirroring.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,29 +62,33 @@ async def compare_index_list(self) -> list[int]:

async def mirroring(self, index_list: list[int]) -> None:
for index in index_list:
has_galleryinfo = False
has_info = False
logger.debug(f"id: {index}")
# Check galleryinfo first
# galleryinfo 먼저 확인
if not await self.galleryinfo_database.get_galleryinfo(index):
logger.debug(f"{index} couldn't find that galleryinfo locally.")
if galleryinfo := await self.request.get_galleryinfo(index):
logger.debug(f"{index} can get galleryinfo from hitomi.la.")
await self.galleryinfo_database.add_galleryinfo(galleryinfo)
if not await self.info_database.get_info(index):
logger.debug(f"{index} couldn't find that info locally.")
await self.info_database.add_info(
Info.from_galleryinfo(galleryinfo)
)
logger.debug(f"Added info {index}.")
else:
logger.debug(f"{index} already has info locally.")
if await self.galleryinfo_database.get_galleryinfo(index):
has_galleryinfo = True

if await self.info_database.get_info(index):
has_info = True

if galleryinfo := await self.request.get_galleryinfo(index):
if has_galleryinfo:
logger.debug(f"{index} already has galleryinfo locally.")
else:
logger.debug(f"{index} couldn't find that info locally.")
await self.galleryinfo_database.add_galleryinfo(galleryinfo)
logger.debug(f"Added galleryinfo {index}.")

if has_info:
logger.debug(f"{index} already has info locally.")
else:
logger.warning(f"{index} can't get galleryinfo from hitomi.la.")
continue
logger.debug(f"{index} couldn't find that galleryinfo locally.")
await self.info_database.add_info(
Info.from_galleryinfo(galleryinfo)
)
logger.debug(f"Added info {index}.")
else:
logger.debug(f"{index} already has galleryinfo locally.")
logger.warning(f"{index} can't get galleryinfo from hitomi.la.")

async def start(self, delay: float) -> NoReturn:
while True:
Expand Down

0 comments on commit 1e74460

Please sign in to comment.