Skip to content

Commit cceda4e

Browse files
committed
feat: 删除 mr version 的同时删除 file
1 parent 7e28b50 commit cceda4e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

mcim_sync/sync/modrinth.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,21 @@ def sync_project_all_version(project_id: str) -> int:
5454
submitter.add(file_model)
5555
submitter.add(Version(**version))
5656

57-
removed_count = mongodb_engine.remove(
57+
removed_version_count = mongodb_engine.remove(
5858
Version,
5959
query.not_in(Version.id, latest_version_id_list),
6060
Version.project_id == project_id,
6161
)
62+
63+
removed_file_count = mongodb_engine.remove(
64+
File,
65+
query.not_in(File.version_id, latest_version_id_list),
66+
File.project_id == project_id,
67+
)
68+
6269
total_count = len(res)
6370
log.info(
64-
f"Finished sync project {project_id} versions info, total {total_count} versions, removed {removed_count} versions"
71+
f"Finished sync project {project_id} versions info, total {total_count} versions, removed {removed_version_count} versions and {removed_file_count} files"
6572
)
6673
return total_count
6774

0 commit comments

Comments
 (0)