--- a/alexandria.py Tue Sep 15 17:30:16 2009 -0700
+++ b/alexandria.py Mon Oct 12 08:16:43 2009 -0700
@@ -250,6 +250,26 @@
_show_paper(paper)
else:
print "No such path %s found" % _colorize_string('path', path)
+
+@command(dbopts,
+ usage='%name PATH')
+def rehash(cfg, path):
+ """Rehash the paper at the given path"""
+
+ m = hashlib.md5()
+ with open(path, 'r') as fd:
+ m.update(fd.read())
+
+ path = _short_path(cfg, path)
+ paper = Paper.get_by(path = path)
+
+ if paper:
+ paper.md5 = m.hexdigest()
+ session.commit()
+
+ _show_paper(paper)
+ else:
+ print "No such path %s found" % _colorize_string('path', path)
def _short_path(cfg, path):
path = os.path.abspath(path)