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

Fix cleanup of files with unicode paths

parent b64e8366
......@@ -202,7 +202,11 @@ class UnknownFile(File):
self._confname = os.path.join('files', hsh)
File.__init__(self, storage, '')
self.read()
self.path = self.data['info'].get('path')
pth = self.data['info'].get('path')
if pth is not None:
self.path = pth.encode('utf-8')
else:
self.path = None
def _get_confname(self):
return self._confname
# -*- coding: utf-8 -*-
from unittest import TestCase
from ass2m.cli import CLI
from ass2m.storage import Storage
......@@ -88,3 +90,12 @@ class CleanupTest(TestCase):
f = self.storage.get_file('/hello')
assert f.data['info'].get('view') is None
assert f.view is None
def test_unicode(self):
with open(os.path.join(self.storage.path, 'files', 'eed3d4c0aac6375a40412d0c4e689d3da85c44d0'), 'w') as f:
f.write('[info]\npath = /héy')
self.beginCapture()
assert self.app.main(['ass2m_test', 'cleanup', '--gc']) in (0, None)
output = self.endCapture()
assert output.strip() == ''
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