Skip to content

Commit

Permalink
Folder: small style improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
lwesterhof committed Aug 1, 2024
1 parent ea74e66 commit f15d663
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,8 @@ def precheck_folder_secure(ctx, coll):
return False

found, last_run = get_last_run_time(ctx, coll)
if (not correct_copytovault_start_status(ctx, coll)
or not misc.last_run_time_acceptable(coll, found, last_run, config.vault_copy_backoff_time)):
return False

return True
return (not correct_copytovault_start_status(ctx, coll)
or not misc.last_run_time_acceptable(coll, found, last_run, config.vault_copy_backoff_time))


def folder_secure(ctx, coll):
Expand Down Expand Up @@ -301,21 +298,15 @@ def check_folder_secure(ctx, coll):
:returns: True when successful
"""
if (not set_can_modify(ctx, coll)
return (not set_can_modify(ctx, coll)
or not retry_attempts(ctx, coll)
or not set_last_run_time(ctx, coll)):
return False

return True
or not set_last_run_time(ctx, coll))


def correct_copytovault_start_status(ctx, coll):
"""Confirm that the copytovault cronjob avu status is correct state to start securing"""
cronjob_status = get_cronjob_status(ctx, coll)
if cronjob_status in (constants.CRONJOB_STATE['PENDING'], constants.CRONJOB_STATE['RETRY']):
return True

return False
return cronjob_status in (constants.CRONJOB_STATE['PENDING'], constants.CRONJOB_STATE['RETRY'])


def get_last_run_time(ctx, coll):
Expand Down Expand Up @@ -357,7 +348,13 @@ def set_can_modify(ctx, coll):


def get_retry_count(ctx, coll):
""" Get the retry count, if not such AVU, return 0 """
"""Get the retry count, if not such AVU, return 0.
:param ctx: Combined type of a callback and rei struct
:param coll: Folder to secure
:returns: Retry count
"""
retry_count = 0
iter = genquery.row_iterator(
"META_COLL_ATTR_VALUE, COLL_NAME",
Expand All @@ -371,13 +368,15 @@ def get_retry_count(ctx, coll):


def retry_attempts(ctx, coll):
""" Check if there have been too many retries. """
retry_count = get_retry_count(ctx, coll)
"""Check if there have been too many retries.
if retry_count >= config.vault_copy_max_retries:
return False
:param ctx: Combined type of a callback and rei struct
:param coll: Folder to secure
return True
:returns: Boolean indicating if there have been too many retries
"""
retry_count = get_retry_count(ctx, coll)
return retry_count >= config.vault_copy_max_retries


def folder_secure_succeed_avus(ctx, coll, group_name):
Expand Down

0 comments on commit f15d663

Please sign in to comment.