Skip to content

Commit

Permalink
Merge branch 'reporter-errors'
Browse files Browse the repository at this point in the history
  • Loading branch information
mjurbanski-reef committed May 8, 2024
2 parents ba628be + a71fc44 commit a7e3a3b
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 5 deletions.
1 change: 1 addition & 0 deletions b2/_internal/b2v3/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from b2._internal._cli.b2api import _get_b2api_for_profile
from b2._internal.arg_parser import enable_camel_case_arguments
from .rm import Rm
from .sync import Sync

enable_camel_case_arguments()

Expand Down
16 changes: 16 additions & 0 deletions b2/_internal/b2v3/sync.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
######################################################################
#
# File: b2/_internal/b2v3/sync.py
#
# Copyright 2024 Backblaze Inc. All Rights Reserved.
#
# License https://www.backblaze.com/using_b2_code.html
#
######################################################################

from b2._internal.b2v4.registry import Sync as SyncV4


class Sync(SyncV4):
__doc__ = SyncV4.__doc__
FAIL_ON_REPORTER_ERRORS_OR_WARNINGS = False
4 changes: 4 additions & 0 deletions b2/_internal/console_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -2995,6 +2995,8 @@ class Sync(
DEFAULT_DOWNLOAD_THREADS = 10
DEFAULT_UPLOAD_THREADS = 10

FAIL_ON_REPORTER_ERRORS_OR_WARNINGS = True

@classmethod
def _setup_parser(cls, parser):
add_normalized_argument(parser, '--no-progress', action='store_true')
Expand Down Expand Up @@ -3112,6 +3114,8 @@ def _run(self, args):
raise CommandError(f'{ex.path} is not a directory')
except UnableToCreateDirectory as ex:
raise CommandError(f'unable to create directory {ex.path}')
if self.FAIL_ON_REPORTER_ERRORS_OR_WARNINGS and reporter.has_errors_or_warnings():
return 1
return 0

def get_policies_manager_from_args(self, args):
Expand Down
1 change: 1 addition & 0 deletions changelog.d/+sync-status-code.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Changed `sync` command exit status code from 0 to 1 if any warnings or errors were encountered during the operation.
8 changes: 4 additions & 4 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ classifiers = [
dependencies = [
"argcomplete>=2,<4",
"arrow>=1.0.2,<2.0.0",
"b2sdk>=2.1.0,<3",
"b2sdk>=2.2.0,<3",
"docutils>=0.18.1",
"idna~=3.4; platform_system == 'Java'",
"importlib-metadata>=3.3; python_version < '3.8'",
Expand Down

0 comments on commit a7e3a3b

Please sign in to comment.