Commit de186149 authored by Laurent Bachelier's avatar Laurent Bachelier

Fix saving None into configs

parent 55a63ed4
......@@ -202,6 +202,11 @@ class CoreCleaner(ICleaner):
f.view = None
f.save()
print "%s: fixed empty view." % f._get_confname()
for user in self.storage.iter_users():
if user.key in ["", "None"]:
user.key = None
user.save()
print "%s: fixed empty key." % f._get_confname()
def gc(self):
for f in self.invalid_paths:
......
......@@ -201,7 +201,8 @@ class Storage(object):
for key, value in items.iteritems():
if isinstance(value, unicode):
value = value.encode('utf-8')
config.set(sec, key, value)
if value is not None:
config.set(sec, key, value)
with open(path, 'wb') as fp:
config.write(fp)
......
......@@ -84,3 +84,7 @@ class CleanupTest(TestCase):
assert self.app.main(['ass2m_test', 'cleanup', '--gc']) in (0, None)
output = self.endCapture()
assert output.strip() == 'files/3be00feb429b32b7705b689475e3ab8bdf16733f: fixed empty view.'
f = self.storage.get_file('/hello')
assert f.data['info'].get('view') is None
assert f.view is None
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