diff --git a/ui/fixtures/cmd.basic.json b/ui/fixtures/cmd.basic.json index c1f473f..b61ffea 100644 --- a/ui/fixtures/cmd.basic.json +++ b/ui/fixtures/cmd.basic.json @@ -111,6 +111,11 @@ "cmd": [ "list", "test.txt" ], "stdout_re": "foo:\tbar=baz\nhashes:\tsha512:90f8342520f0ac57fb5a779f5d331c2fa87aa40f8799940257f9ba619940951e67143a8d746535ed0284924b2b7bc1478f095198800ba96d01847d7b56ca465c\nsig:\t.*\ntag:\t\n" }, +{ + "special": "verify store object cnt", + "comment": "should have two file and one metadata", + "count": 3 +}, { "special": "change newfile.txt" }, diff --git a/ui/medashare/cli.py b/ui/medashare/cli.py index 38c4cc7..ed219af 100644 --- a/ui/medashare/cli.py +++ b/ui/medashare/cli.py @@ -490,7 +490,14 @@ class ObjectStore(object): return self._hashes[h] def by_file(self, fname, types=('metadata', )): - '''Return a metadata object for the file named fname.''' + '''Return a metadata object for the file named fname. + + Will raise a KeyError if this file does not exist in + the database. + + Will raise a ValueError if fname currently does not + match what is in the database. + ''' fid = FileObject.make_id(fname) @@ -556,7 +563,9 @@ class FileObject(MDBase): def verify(self, complete=False): '''Verify that this FileObject is still valid. It will - by default, only do a mtime verification.''' + by default, only do a mtime verification. + + It will raise a ValueError if the file does not match.''' s = os.stat(os.path.join(self.dir, self.filename)) mtimets = datetime.datetime.fromtimestamp(s.st_mtime, @@ -728,6 +737,12 @@ def cmd_list(options): #print >>sys.stderr, `j._obj` for k, v in _iterdictlist(j): print('%s:\t%s' % (k, v)) + + # This is needed so that if it creates a FileObj, which may be + # expensive (hashing large file), that it gets saved. + + write_objstore(options, objstr) + def main(): import argparse