Skip to content

Commit

Permalink
Sync同步逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
lee-cq committed Dec 25, 2023
1 parent aa57232 commit 5404399
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
10 changes: 6 additions & 4 deletions alist_sync/run_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from alist_sync.common import async_all_task_names
from alist_sync.job_copy import CopyJob
from alist_sync.models import AlistServer
from alist_sync.scanner import scan_dirs

logger = logging.getLogger("alist-sync.copy-to-target")

Expand All @@ -24,8 +23,11 @@ async def async_run(self):
"""异步运行"""
await super().async_run()
checker = await check_dir(*self.sync_dirs, client=self.client)
copy_job = CopyJob.from_checker(self.source_path, self.targets_path, checker)
copy_job = CopyJob.from_checker(
self.source_path,
self.targets_path,
checker,
)
await copy_job.start(self.client)
logger.info("当前全部的Task %s", async_all_task_names())

logger.info("复制完成。")
logger.info("复制完成。")
26 changes: 22 additions & 4 deletions alist_sync/run_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,29 @@
各个Dir分别成为源目录,并Copy至其他目录
"""
import logging

from alist_sync.base_sync import SyncBase
from alist_sync.checker import check_dir
from alist_sync.job_copy import CopyJob
from alist_sync.models import AlistServer
from alist_sync.run_copy import Copy

logger = logging.getLogger("alist-sync.run-sync")


class Sync:
class Sync(SyncBase):
def __init__(self, alist_info: AlistServer, dirs: list[str] = None):
# TODO 重构Base 以完成更高的效率
pass
super().__init__(alist_info, dirs)

async def async_run(self):
"""异步运行"""
await super().async_run()
checker = await check_dir(*self.sync_dirs, client=self.client)
copy_job = CopyJob.from_checker(
self.sync_dirs,
self.sync_dirs,
checker,
)

await copy_job.start(self.client)
logger.info("同步完成。")

0 comments on commit 5404399

Please sign in to comment.