mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-03-25 08:55:50 +00:00
Make /storage/filesystem more flexible
by adding the optional fileignoreext parameter.
This commit is contained in:
parent
439e63f8ea
commit
81895c291e
2 changed files with 7 additions and 2 deletions
|
|
@ -408,6 +408,7 @@ Local
|
|||
fileext = "..."
|
||||
#encoding = "utf-8"
|
||||
#post_hook = null
|
||||
#fileextignore = ".tmp"
|
||||
|
||||
Can be used with `khal <http://lostpackets.de/khal/>`_. See :doc:`vdir` for
|
||||
a more formal description of the format.
|
||||
|
|
@ -426,6 +427,8 @@ Local
|
|||
:param post_hook: A command to call for each item creation and
|
||||
modification. The command will be called with the path of the
|
||||
new/updated file.
|
||||
:param fileextignore: The file extention to ignore,
|
||||
the default is ``.tmp``.
|
||||
|
||||
.. storage:: singlefile
|
||||
|
||||
|
|
|
|||
|
|
@ -22,13 +22,15 @@ class FilesystemStorage(Storage):
|
|||
storage_name = "filesystem"
|
||||
_repr_attributes = ("path",)
|
||||
|
||||
def __init__(self, path, fileext, encoding="utf-8", post_hook=None, **kwargs):
|
||||
def __init__(self, path, fileext,
|
||||
encoding="utf-8", post_hook=None, fileignoreext=".tmp", **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
path = expand_path(path)
|
||||
checkdir(path, create=False)
|
||||
self.path = path
|
||||
self.encoding = encoding
|
||||
self.fileext = fileext
|
||||
self.fileignoreext = fileignoreext
|
||||
self.post_hook = post_hook
|
||||
|
||||
@classmethod
|
||||
|
|
@ -81,7 +83,7 @@ class FilesystemStorage(Storage):
|
|||
for fname in os.listdir(self.path):
|
||||
fpath = os.path.join(self.path, fname)
|
||||
if os.path.isfile(fpath) and fname.endswith(self.fileext) and (
|
||||
not fname.endswith('.tmp')):
|
||||
not fname.endswith(self.fileignoreext)):
|
||||
yield fname, get_etag_from_file(fpath)
|
||||
|
||||
def get(self, href):
|
||||
|
|
|
|||
Loading…
Reference in a new issue