Esempio n. 1
0
 def handle(self, *args, **options):
     self.repo = options["repo"]
     self.vcs = GridVCS(self.repo)
     if self.repo in self.clean_int:
         self.clean_id = lambda y: int(y)
     else:
         self.clean_id = lambda y: y
     return getattr(self, "handle_%s" % options["cmd"])(*args, **options)
Esempio n. 2
0
def fix_repo(repo):
    vcs = GridVCS(repo)
    # Get files without chunk 0
    revs = set(d["_id"] for d in vcs.fs._GridFS__files.find({}, {"_id": 1}))
    chunks = set(
        d["files_id"]
        for d in vcs.fs._GridFS__chunks.find({"n": 0}, {"files_id": 1}))
    corrupt_files = revs - chunks
    if not corrupt_files:
        return
    # Reduce to corrupt objects
    corrupt_objects = set(d["object"] for d in vcs.fs._GridFS__files.find(
        {"_id": {
            "$in": list(corrupt_files)
        }}, {
            "_id": 0,
            "object": 1
        }))
    for obj in corrupt_objects:
        fix_object(vcs, obj, corrupt_files)
Esempio n. 3
0
 def index_gridvcs(self):
     for repo in REPOS:
         GridVCS(repo).ensure_collection()