init biliup-next
This commit is contained in:
27
src/biliup_next/infra/comment_flag_migration.py
Normal file
27
src/biliup_next/infra/comment_flag_migration.py
Normal file
@ -0,0 +1,27 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
class CommentFlagMigrationService:
|
||||
def migrate(self, session_dir: Path) -> dict[str, int]:
|
||||
migrated_split_flags = 0
|
||||
legacy_untracked_full = 0
|
||||
if not session_dir.exists():
|
||||
return {"migrated_split_flags": 0, "legacy_untracked_full": 0}
|
||||
|
||||
for folder in sorted(p for p in session_dir.iterdir() if p.is_dir()):
|
||||
comment_done = folder / "comment_done.flag"
|
||||
split_done = folder / "comment_split_done.flag"
|
||||
full_done = folder / "comment_full_done.flag"
|
||||
if not comment_done.exists():
|
||||
continue
|
||||
if not split_done.exists():
|
||||
split_done.touch()
|
||||
migrated_split_flags += 1
|
||||
if not full_done.exists():
|
||||
legacy_untracked_full += 1
|
||||
return {
|
||||
"migrated_split_flags": migrated_split_flags,
|
||||
"legacy_untracked_full": legacy_untracked_full,
|
||||
}
|
||||
Reference in New Issue
Block a user