Skip to content

Commit

Permalink
fix: internal changes
Browse files Browse the repository at this point in the history
  • Loading branch information
legnaleurc committed Jan 3, 2024
1 parent 26d3cc9 commit 03e79bf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions drive/app/faststart/_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ async def __call__(
getLogger(__name__).info("already cached, skip")
return False

if not cache_only and not await has_enough_quota(self.drive, self.node.size):
if not cache_only and not has_enough_quota(self.drive, self.node.size):
getLogger(__name__).info("not enough quota, skip")
return False

Expand Down Expand Up @@ -400,8 +400,8 @@ async def wait_for_sync(drive: Drive):
getLogger(__name__).debug(change)


async def has_enough_quota(drive: Drive, size: int) -> bool:
total = await get_daily_usage(drive)
def has_enough_quota(drive: Drive, size: int) -> bool:
total = get_daily_usage(drive)
return (total + size) < DAILY_UPLOAD_QUOTA


Expand Down
6 changes: 3 additions & 3 deletions drive/app/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
from wcpan.drive.cli.lib import create_drive_from_config


async def get_daily_usage(drive: Drive) -> int:
def get_daily_usage(drive: Drive) -> int:
now = datetime.now(UTC)
yesterday = now - timedelta(days=1)
dsn = _get_dsn(drive)
return await get_uploaded_size(
return get_uploaded_size(
dsn, int(yesterday.timestamp()), int(now.timestamp())
)


def _get_dsn(drive: Drive) -> str:
return drive._ss._dsn # type: ignore
return drive._ss._bg._dsn # type: ignore


def get_default_config_path() -> Path:
Expand Down

0 comments on commit 03e79bf

Please sign in to comment.