Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
legnaleurc committed Dec 14, 2023
1 parent 8e2d76a commit a1ca406
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions driveutil/fix-hah/app/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from pathlib import Path
from tempfile import TemporaryDirectory

from wcpan.drive.core.types import Drive, Node
from wcpan.drive.cli.lib import create_drive_from_config
from wcpan.logging import ConfigBuilder

Expand Down Expand Up @@ -32,11 +33,7 @@ async def main(args: list[str]) -> int:
children = (_ for _ in children if _is_hah_name(_.name))

for child in children:
src_path = await download(drive, child, work_path)
tmp_path = await archive(src_path, work_path)
await upload(drive, tmp_path, node)
await drive.move(child, trashed=True)
print(f"remove {child}")
await _migrate(drive, child, work_path, node)
await sleep(60)
return 0

Expand All @@ -46,3 +43,11 @@ def _is_hah_name(name: str) -> bool:

rv = re.search(r"\[\d+\]$", name)
return rv is not None


async def _migrate(drive: Drive, src: Node, tmp: Path, parent: Node) -> None:
src_path = await download(drive, src, tmp)
tmp_path = await archive(src_path, tmp)
await upload(drive, tmp_path, parent)
await drive.move(src, trashed=True)
print(f"remove {src}")

0 comments on commit a1ca406

Please sign in to comment.