Commit 0a2f44d4 authored by Laurent Bachelier's avatar Laurent Bachelier

Move some legacy code to the cleaner

parent 28fc2f21
......@@ -175,8 +175,6 @@ class File(IObject):
def _postread(self):
self.view =['info'].get('view', None)
self.mimetype =['info'].get('mimetype', None)
if self.view in ["", "None"]:
self.view = None
for key, value in'perms', {}).iteritems():
self.perms[key] = int(value)
......@@ -197,6 +197,11 @@ class CoreCleaner(ICleaner):
if f.path is None or f._get_confname() != File._get_confname(f):
print "%s has an invalid path: %s." % (f._get_confname(), f.path)
if f.view in ["", "None"]:
f.view = None
print "%s: fixed empty view." % f._get_confname()
def gc(self):
for f in self.invalid_paths:
......@@ -75,3 +75,12 @@ class CleanupTest(TestCase):
assert['ass2m_test', 'cleanup', '--gc']) in (0, None)
output = self.endCapture()
assert output.strip() == 'files/c93c3312483174a3170ebe7395612c404a0620d0 has an invalid path: /hello.\nRemoved files/c93c3312483174a3170ebe7395612c404a0620d0.'
def test_oldStorageBug(self):
with open(os.path.join(, 'files', '3be00feb429b32b7705b689475e3ab8bdf16733f'), 'w') as f:
f.write('[info]\npath = /hello\nview = None')
assert['ass2m_test', 'cleanup', '--gc']) in (0, None)
output = self.endCapture()
print output.strip() == 'files/3be00feb429b32b7705b689475e3ab8bdf16733f: fixed empty view.'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment