MCPcopy
hub / github.com/pimutils/vdirsyncer / upload

Method upload

vdirsyncer/storage/filesystem.py:96–118  ·  view source on GitHub ↗
(self, item)

Source from the content-addressed store, hash-verified

94 raise
95
96 def upload(self, item):
97 if not isinstance(item.raw, str):
98 raise TypeError('item.raw must be a unicode string.')
99
100 try:
101 href = self._get_href(item.ident)
102 fpath, etag = self._upload_impl(item, href)
103 except OSError as e:
104 if e.errno in (
105 errno.ENAMETOOLONG, # Unix
106 errno.ENOENT # Windows
107 ):
108 logger.debug('UID as filename rejected, trying with random '
109 'one.')
110 # random href instead of UID-based
111 href = self._get_href(None)
112 fpath, etag = self._upload_impl(item, href)
113 else:
114 raise
115
116 if self.post_hook:
117 self._run_post_hook(fpath)
118 return href, etag
119
120 def _upload_impl(self, item, href):
121 fpath = self._get_filepath(href)

Callers

nothing calls this directly

Calls 3

_get_hrefMethod · 0.95
_upload_implMethod · 0.95
_run_post_hookMethod · 0.95

Tested by

no test coverage detected