mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-03-25 08:55:50 +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.upload(Item(u'UID:a/b/c'))
|
||||
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:
|
||||
for collection in collections:
|
||||
collection_path = os.path.join(path, collection)
|
||||
if os.path.isdir(collection_path):
|
||||
args = dict(collection=collection, path=collection_path,
|
||||
**kwargs)
|
||||
yield args
|
||||
if not cls._validate_collection(collection_path):
|
||||
continue
|
||||
args = dict(collection=collection, path=collection_path,
|
||||
**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
|
||||
def create_collection(cls, collection, **kwargs):
|
||||
|
|
|
|||
Loading…
Reference in a new issue