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 = self.data['info'].get('view', None)
self.mimetype = self.data['info'].get('mimetype', None)
if self.view in ["", "None"]:
self.view = None
self.perms.clear()
for key, value in self.data.get('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)
self.invalid_paths.append(f)
else:
if f.view in ["", "None"]:
f.view = None
f.save()
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 self.app.main(['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(self.storage.path, 'files', '3be00feb429b32b7705b689475e3ab8bdf16733f'), 'w') as f:
f.write('[info]\npath = /hello\nview = None')
self.beginCapture()
assert self.app.main(['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