mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
parent
feea65ff1d
commit
a285c555f0
2 changed files with 22 additions and 4 deletions
|
|
@ -77,3 +77,10 @@ class TestFilesystemStorage(StorageTests):
|
||||||
s = self.storage_class(str(tmpdir), '.txt', post_hook=exe)
|
s = self.storage_class(str(tmpdir), '.txt', post_hook=exe)
|
||||||
s.upload(Item(u'UID:a/b/c'))
|
s.upload(Item(u'UID:a/b/c'))
|
||||||
assert calls
|
assert calls
|
||||||
|
|
||||||
|
def test_ignore_git_dirs(self, tmpdir):
|
||||||
|
tmpdir.mkdir('.git').mkdir('foo')
|
||||||
|
tmpdir.mkdir('a')
|
||||||
|
tmpdir.mkdir('b')
|
||||||
|
assert set(c['collection'] for c
|
||||||
|
in self.storage_class.discover(str(tmpdir))) == {'a', 'b'}
|
||||||
|
|
|
||||||
|
|
@ -62,10 +62,21 @@ class FilesystemStorage(Storage):
|
||||||
else:
|
else:
|
||||||
for collection in collections:
|
for collection in collections:
|
||||||
collection_path = os.path.join(path, collection)
|
collection_path = os.path.join(path, collection)
|
||||||
if os.path.isdir(collection_path):
|
if not cls._validate_collection(collection_path):
|
||||||
args = dict(collection=collection, path=collection_path,
|
continue
|
||||||
**kwargs)
|
args = dict(collection=collection, path=collection_path,
|
||||||
yield args
|
**kwargs)
|
||||||
|
yield args
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _validate_collection(cls, path):
|
||||||
|
if not os.path.isdir(path):
|
||||||
|
return False
|
||||||
|
for item in os.listdir(path):
|
||||||
|
item_path = os.path.join(path, item)
|
||||||
|
if os.path.isdir(item_path):
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create_collection(cls, collection, **kwargs):
|
def create_collection(cls, collection, **kwargs):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue