Browse Source

if list creates a file, write it out..

main
John-Mark Gurney 2 years ago
parent
commit
37212a4c08
2 changed files with 22 additions and 2 deletions
  1. +5
    -0
      ui/fixtures/cmd.basic.json
  2. +17
    -2
      ui/medashare/cli.py

+ 5
- 0
ui/fixtures/cmd.basic.json View File

@@ -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"
},


+ 17
- 2
ui/medashare/cli.py View File

@@ -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



Loading…
Cancel
Save