Ronny Pfannschmidt avatar Ronny Pfannschmidt committed 41678b1

complete the store check command

Comments (0)

Files changed (2)

 
 parser.add_argument('-s', '--store', required=True)
 parser.add_argument('-d', '--debug', action='store_true')
+parser.add_argument('-c', '--check', action='store_true')
 parser.add_argument('--backup', default=[], action='append')
 
 from bmst.backup_app import make_backup
-from bmst.managed import BMST
+from bmst.managed import BMST, check_bmst
 from bmst.store import FileStore
 
 
     print('using store', bmst)
     bmst = get_bmst(bmst)
 
+    if opts.check:
+        check_bmst(bmst)
+
     for to_backup in opts.backup:
         path = py.path.local(to_backup)
         make_backup(root=path, bmst=bmst)
 def check_meta(bmst):
     all_missing = {}
     for item in bmst.meta:
-        data = bmst.get_meta(item)
+        data = bmst.load_meta(item)
         missing = find_missing_blobs(data['items'], bmst.blobs)
         if missing:
-            print 'E: missing blobs for meta, item'
+            print 'E: missing blobs for meta, item', item
             all_missing[item] = missing
+    return all_missing
 
 
 def check_bmst(bmst):
+    results = []
+    print 'checking blobs'
     check_store(bmst.blobs, 'blob')
+    print 'checking meta'
     check_store(bmst.meta, 'meta')
+    print 'checking references'
     check_meta(bmst)
+    #XXX: orphan blobs
 
 
 def encode_data(raw_data, key):
 
         return key
 
+    def load_meta(self, key):
+        return json.loads(bz2.decompress(self.meta[key]))
+
     def store_blob(self, key=None, data=None):
         key, encoded = encode_data(data, key)
         self.blobs[key] = encoded
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.