mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +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 = "..."
|
fileext = "..."
|
||||||
#encoding = "utf-8"
|
#encoding = "utf-8"
|
||||||
#post_hook = null
|
#post_hook = null
|
||||||
|
#fileextignore = ".tmp"
|
||||||
|
|
||||||
Can be used with `khal <http://lostpackets.de/khal/>`_. See :doc:`vdir` for
|
Can be used with `khal <http://lostpackets.de/khal/>`_. See :doc:`vdir` for
|
||||||
a more formal description of the format.
|
a more formal description of the format.
|
||||||
|
|
@ -426,6 +427,8 @@ Local
|
||||||
:param post_hook: A command to call for each item creation and
|
:param post_hook: A command to call for each item creation and
|
||||||
modification. The command will be called with the path of the
|
modification. The command will be called with the path of the
|
||||||
new/updated file.
|
new/updated file.
|
||||||
|
:param fileextignore: The file extention to ignore,
|
||||||
|
the default is ``.tmp``.
|
||||||
|
|
||||||
.. storage:: singlefile
|
.. storage:: singlefile
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,13 +22,15 @@ class FilesystemStorage(Storage):
|
||||||
storage_name = "filesystem"
|
storage_name = "filesystem"
|
||||||
_repr_attributes = ("path",)
|
_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)
|
super().__init__(**kwargs)
|
||||||
path = expand_path(path)
|
path = expand_path(path)
|
||||||
checkdir(path, create=False)
|
checkdir(path, create=False)
|
||||||
self.path = path
|
self.path = path
|
||||||
self.encoding = encoding
|
self.encoding = encoding
|
||||||
self.fileext = fileext
|
self.fileext = fileext
|
||||||
|
self.fileignoreext = fileignoreext
|
||||||
self.post_hook = post_hook
|
self.post_hook = post_hook
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
@ -81,7 +83,7 @@ class FilesystemStorage(Storage):
|
||||||
for fname in os.listdir(self.path):
|
for fname in os.listdir(self.path):
|
||||||
fpath = os.path.join(self.path, fname)
|
fpath = os.path.join(self.path, fname)
|
||||||
if os.path.isfile(fpath) and fname.endswith(self.fileext) and (
|
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)
|
yield fname, get_etag_from_file(fpath)
|
||||||
|
|
||||||
def get(self, href):
|
def get(self, href):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue