diff --git a/flask_annex/file.py b/flask_annex/file.py index 3d6d8ba..6ed8cf0 100644 --- a/flask_annex/file.py +++ b/flask_annex/file.py @@ -36,9 +36,10 @@ def _clean_empty_dirs(self, key): try: os.rmdir(dir_name) except OSError as e: - if e.errno != errno.ENOTEMPTY: + if e.errno == errno.ENOTEMPTY: + break + if e.errno != errno.ENOENT: raise # pragma: no cover - break key_dir_name = os.path.dirname(key_dir_name) diff --git a/tests/helpers.py b/tests/helpers.py index b2a66fe..9c90042 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -79,5 +79,5 @@ def test_delete_nonexistent(self, annex): def test_delete_many(self, annex): assert annex.list_keys('') - annex.delete_many(('foo/bar.txt', 'foo/baz.json', '@@nonexistent')) + annex.delete_many(('foo/bar.txt', 'foo/baz.json', 'foo/@@nonexistent')) assert not annex.list_keys('')