Skip to content

Commit

Permalink
sync status code 1 on warnings/errors
Browse files Browse the repository at this point in the history
  • Loading branch information
adal-chiriliuc-reef committed May 3, 2024
1 parent 160e9d1 commit 1b99127
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 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 @@ -2972,6 +2972,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 @@ -3089,6 +3091,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.

0 comments on commit 1b99127

Please sign in to comment.