diff --git a/CHANGELOG.md b/CHANGELOG.md index 93a9b9a6d..571f4c88e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,13 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -### Added +### Deprecated -* Support '-' as stdout alias +* Support of `-` as a valid filename in `download-file-by-name` or `download-file-by-id` command. In future `-` will be an alias for standard output. ### Fixed -* Fix unable to use '/dev/stdout' by checking the localFileName if that present the `STDOUT` of OS +* Fix unable to use `/dev/stdout` by checking the localFileName if that present the `STDOUT` of OS ### Infrastructure * Fix gathering licenses of typeshed libraries diff --git a/b2/console_tool.py b/b2/console_tool.py index 050f24fb1..a0b8c22b6 100644 --- a/b2/console_tool.py +++ b/b2/console_tool.py @@ -1369,21 +1369,17 @@ class DownloadFileMixin( MaxDownloadStreamsMixin, DownloadCommand, ): - def get_download_info_from_local_filename(self, filename: str): - stdout_file_path = 'CON' if platform.system() == 'Windows' else '/dev/stdout' + STDOUT_FILE_PATH = 'CON' if platform.system() == 'Windows' else '/dev/stdout' + def _correct_local_filename(self, filename: str): if filename == '-': if os.path.exists('-'): self._print_stderr( "WARNING: Filename `-` won't be supported in the future and will be treated as stdout alias." ) - return filename, 'wb+', True - return stdout_file_path, 'wb', False - - allow_seeking = filename != stdout_file_path - mode = 'wb+' if allow_seeking else 'wb' - - return filename, mode, allow_seeking + return filename + return self.STDOUT_FILE_PATH + return filename @B2.register_subcommand @@ -1413,9 +1409,7 @@ def _setup_parser(cls, parser): super()._setup_parser(parser) def run(self, args): - local_filename, mode, allow_seeking = self.get_download_info_from_local_filename( - args.localFileName - ) + local_filename = self._correct_local_filename(args.localFileName) progress_listener = make_progress_listener(local_filename, args.noProgress) encryption_setting = self._get_source_sse_setting(args) @@ -1424,7 +1418,7 @@ def run(self, args): args.fileId, progress_listener, encryption=encryption_setting ) self._print_download_info(downloaded_file) - downloaded_file.save_to(local_filename, mode, allow_seeking) + downloaded_file.save_to(local_filename) self._print('Download finished') return 0 @@ -1456,9 +1450,7 @@ def _setup_parser(cls, parser): super()._setup_parser(parser) def run(self, args): - local_filename, mode, allow_seeking = self.get_download_info_from_local_filename( - args.localFileName - ) + local_filename = self._correct_local_filename(args.localFileName) self._set_threads_from_args(args) bucket = self.api.get_bucket_by_name(args.bucketName) @@ -1468,7 +1460,7 @@ def run(self, args): args.b2FileName, progress_listener, encryption=encryption_setting ) self._print_download_info(downloaded_file) - downloaded_file.save_to(local_filename, mode, allow_seeking) + downloaded_file.save_to(local_filename, 'wb', True) self._print('Download finished') return 0