| 179 | dry_run: bool |
| 180 | |
| 181 | def upload_file(self, bucket: str, key: str, path: Path) -> None: |
| 182 | print(f"uploading {path.name} -> s3://{bucket}/{key}") |
| 183 | if self.dry_run: |
| 184 | return |
| 185 | |
| 186 | if self.client is None or self.transfer_config is None: |
| 187 | raise MirrorError("S3 client not initialised") |
| 188 | |
| 189 | try: |
| 190 | self.client.upload_file( |
| 191 | str(path), |
| 192 | bucket, |
| 193 | key, |
| 194 | ExtraArgs={"CacheControl": CACHE_CONTROL}, |
| 195 | Config=self.transfer_config, |
| 196 | ) |
| 197 | except Exception as e: |
| 198 | raise MirrorError(f"failed to upload {path.name}: {e}") from e |
| 199 | |
| 200 | |
| 201 | def main(argv: Sequence[str] | None = None) -> int: |