Skip to content

Commit 81895c2

Browse files
Make /storage/filesystem more flexible
by adding the optional fileignoreext parameter.
1 parent 439e63f commit 81895c2

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

docs/config.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ Local
408408
fileext = "..."
409409
#encoding = "utf-8"
410410
#post_hook = null
411+
#fileextignore = ".tmp"
411412

412413
Can be used with `khal <http://lostpackets.de/khal/>`_. See :doc:`vdir` for
413414
a more formal description of the format.
@@ -426,6 +427,8 @@ Local
426427
:param post_hook: A command to call for each item creation and
427428
modification. The command will be called with the path of the
428429
new/updated file.
430+
:param fileextignore: The file extention to ignore,
431+
the default is ``.tmp``.
429432

430433
.. storage:: singlefile
431434

vdirsyncer/storage/filesystem.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ class FilesystemStorage(Storage):
2222
storage_name = "filesystem"
2323
_repr_attributes = ("path",)
2424

25-
def __init__(self, path, fileext, encoding="utf-8", post_hook=None, **kwargs):
25+
def __init__(self, path, fileext,
26+
encoding="utf-8", post_hook=None, fileignoreext=".tmp", **kwargs):
2627
super().__init__(**kwargs)
2728
path = expand_path(path)
2829
checkdir(path, create=False)
2930
self.path = path
3031
self.encoding = encoding
3132
self.fileext = fileext
33+
self.fileignoreext = fileignoreext
3234
self.post_hook = post_hook
3335

3436
@classmethod
@@ -81,7 +83,7 @@ def list(self):
8183
for fname in os.listdir(self.path):
8284
fpath = os.path.join(self.path, fname)
8385
if os.path.isfile(fpath) and fname.endswith(self.fileext) and (
84-
not fname.endswith('.tmp')):
86+
not fname.endswith(self.fileignoreext)):
8587
yield fname, get_etag_from_file(fpath)
8688

8789
def get(self, href):

0 commit comments

Comments
 (0)