|
a/scripts/refresh-all-repos.py |
|
b/scripts/refresh-all-repos.py |
|
... |
|
... |
30 |
M.repo.CommitDoc.m.remove({})
|
30 |
M.repo.CommitDoc.m.remove({})
|
31 |
M.repo.TreeDoc.m.remove({})
|
31 |
M.repo.TreeDoc.m.remove({})
|
32 |
M.repo.TreesDoc.m.remove({})
|
32 |
M.repo.TreesDoc.m.remove({})
|
33 |
M.repo.DiffInfoDoc.m.remove({})
|
33 |
M.repo.DiffInfoDoc.m.remove({})
|
34 |
M.repo.CommitRunDoc.m.remove({})
|
34 |
M.repo.CommitRunDoc.m.remove({})
|
|
|
35 |
M.repo.LastCommitDoc.m.remove({})
|
35 |
|
36 |
|
36 |
for chunk in chunked_find(M.Project, q_project):
|
37 |
for chunk in chunked_find(M.Project, q_project):
|
37 |
for p in chunk:
|
38 |
for p in chunk:
|
38 |
log.info("Refreshing repos for project '%s'." % p.shortname)
|
39 |
log.info("Refreshing repos for project '%s'." % p.shortname)
|
39 |
if options.dry_run:
|
40 |
if options.dry_run:
|
|
... |
|
... |
70 |
# exceed the max BSON size limit (16MB at the moment)
|
71 |
# exceed the max BSON size limit (16MB at the moment)
|
71 |
for tree_ids_chunk in chunked_list(tree_ids, 300000):
|
72 |
for tree_ids_chunk in chunked_list(tree_ids, 300000):
|
72 |
i = M.repo.TreeDoc.m.find({"_id": {"$in": tree_ids_chunk}}).count()
|
73 |
i = M.repo.TreeDoc.m.find({"_id": {"$in": tree_ids_chunk}}).count()
|
73 |
log.info("Deleting %i TreeDoc docs...", i)
|
74 |
log.info("Deleting %i TreeDoc docs...", i)
|
74 |
M.repo.TreeDoc.m.remove({"_id": {"$in": tree_ids_chunk}})
|
75 |
M.repo.TreeDoc.m.remove({"_id": {"$in": tree_ids_chunk}})
|
75 |
i = M.repo.LastCommitDoc.m.find({"object_id": {"$in": tree_ids_chunk}}).count()
|
|
|
76 |
log.info("Deleting %i LastCommitDoc docs...", i)
|
|
|
77 |
M.repo.LastCommitDoc.m.remove({"object_id": {"$in": tree_ids_chunk}})
|
|
|
78 |
del tree_ids
|
76 |
del tree_ids
|
79 |
|
77 |
|
80 |
# delete these after TreeDoc and LastCommitDoc so that if
|
78 |
# delete these after TreeDoc and LastCommitDoc so that if
|
81 |
# we crash, we don't lose the ability to delete those
|
79 |
# we crash, we don't lose the ability to delete those
|
82 |
i = M.repo.TreesDoc.m.find({"_id": {"$in": ci_ids}}).count()
|
80 |
i = M.repo.TreesDoc.m.find({"_id": {"$in": ci_ids}}).count()
|
83 |
log.info("Deleting %i TreesDoc docs...", i)
|
81 |
log.info("Deleting %i TreesDoc docs...", i)
|
84 |
M.repo.TreesDoc.m.remove({"_id": {"$in": ci_ids}})
|
82 |
M.repo.TreesDoc.m.remove({"_id": {"$in": ci_ids}})
|
85 |
|
83 |
|
86 |
# delete LastCommitDocs for non-trees
|
84 |
# delete LastCommitDocs
|
87 |
repo_lastcommit_re = re.compile("^{}:".format(c.app.repo._id))
|
|
|
88 |
i = M.repo.LastCommitDoc.m.find(dict(_id=repo_lastcommit_re)).count()
|
85 |
i = M.repo.LastCommitDoc.m.find(dict(commit_ids={'$in': ci_ids})).count()
|
89 |
log.info("Deleting %i remaining LastCommitDoc docs, by repo id...", i)
|
86 |
log.info("Deleting %i remaining LastCommitDoc docs, by repo id...", i)
|
90 |
M.repo.LastCommitDoc.m.remove(dict(_id=repo_lastcommit_re))
|
87 |
M.repo.LastCommitDoc.m.remove(dict(commit_ids={'$in': ci_ids}))
|
91 |
|
88 |
|
92 |
i = M.repo.DiffInfoDoc.m.find({"_id": {"$in": ci_ids}}).count()
|
89 |
i = M.repo.DiffInfoDoc.m.find({"_id": {"$in": ci_ids}}).count()
|
93 |
log.info("Deleting %i DiffInfoDoc docs...", i)
|
90 |
log.info("Deleting %i DiffInfoDoc docs...", i)
|
94 |
M.repo.DiffInfoDoc.m.remove({"_id": {"$in": ci_ids}})
|
91 |
M.repo.DiffInfoDoc.m.remove({"_id": {"$in": ci_ids}})
|
95 |
|
92 |
|