(self, item)
| 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) |
nothing calls this directly
no test coverage detected