blackboardsync
Advanced tools
| import uuid | ||
| import mimetypes | ||
@@ -18,3 +19,15 @@ from pathlib import Path | ||
| job: DownloadJob): | ||
| self.filename = attachment.fileName | ||
| filename = attachment.fileName or str(uuid.uuid1()) | ||
| name_ext = '.' + filename.split('.')[-1] | ||
| # Guess extension based on content | ||
| mime = attachment.mimeType or 'text/plain' | ||
| real_ext = mimetypes.guess_extension(mime, strict=False) | ||
| possible_ext = mimetypes.guess_all_extensions(mime, strict=False) | ||
| if name_ext in possible_ext: | ||
| self.filename = filename | ||
| else: | ||
| self.filename = filename + real_ext | ||
| self.stream = job.session.download(attachment_id=attachment.id, | ||
@@ -24,3 +37,2 @@ **api_path) | ||
| def write(self, path: Path, executor: ThreadPoolExecutor) -> None: | ||
| filename = self.filename or str(uuid.uuid1()) | ||
| super().write_base(path / filename, executor, self.stream) | ||
| super().write_base(path / self.filename, executor, self.stream) |
@@ -41,3 +41,3 @@ import logging | ||
| self.title = content.title_path_safe | ||
| self.title = content.title_path_safe.replace('.', '_') | ||
@@ -44,0 +44,0 @@ try: |
@@ -157,4 +157,4 @@ """ | ||
| self.log_out() | ||
| except RequestException: | ||
| logger.exception("Network failure") | ||
| except (RequestException, OSError): | ||
| logger.exception("Download error") | ||
| self._has_error = True | ||
@@ -161,0 +161,0 @@ |
| Metadata-Version: 2.1 | ||
| Name: blackboardsync | ||
| Version: 0.17.0 | ||
| Version: 0.17.1rc1 | ||
| Summary: Sync your blackboard content to your device | ||
@@ -5,0 +5,0 @@ Author-email: Jacob Sánchez <jacobszpz@protonmail.com> |
+7
-0
@@ -9,2 +9,9 @@ # Changelog | ||
| ### Fixed | ||
| - Name conflict between content and attachment | ||
| - Handle OSError in download workers | ||
| - Folder names should not contain dots | ||
| ## [0.17.0] - 2024-09-20 | ||
| ### Changed | ||
@@ -11,0 +18,0 @@ - Remove hardcoded minimum year in setup wizard |
+1
-1
| Metadata-Version: 2.1 | ||
| Name: blackboardsync | ||
| Version: 0.17.0 | ||
| Version: 0.17.1rc1 | ||
| Summary: Sync your blackboard content to your device | ||
@@ -5,0 +5,0 @@ Author-email: Jacob Sánchez <jacobszpz@protonmail.com> |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
644363
0.09%4688
0.19%