Add debugging instrumentation to help diagnose #713.
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Dan Helfman 2023-06-19 22:05:40 -07:00
parent 7b8be800a4
commit 11653785ea
1 changed files with 20 additions and 3 deletions

View File

@ -8,7 +8,7 @@ import os
import pathlib
from borgmatic.borg import environment, extract, feature, flags, rinfo, state
from borgmatic.execute import DO_NOT_CAPTURE, execute_command
from borgmatic.execute import DO_NOT_CAPTURE, execute_command, execute_command_and_capture_output
DEFAULT_CHECKS = (
{'name': 'repository', 'frequency': '1 month'},
@ -336,23 +336,40 @@ def upgrade_check_times(location_config, borg_repository_id):
~/.borgmatic/checks/1234567890/archives/all
'''
logger.debug(f"#713: upgrade_check_times(location_config={location_config}, borg_repository_id='{borg_repository_id}')")
for check_type in ('archives', 'data'):
logger.debug(f"#713: check_type = '{check_type}'")
new_path = make_check_time_path(location_config, borg_repository_id, check_type, 'all')
logger.debug(f"#713: new_path = '{new_path}'")
old_path = os.path.dirname(new_path)
logger.debug(f"#713: old_path = '{old_path}'")
temporary_path = f'{old_path}.temp'
logger.debug(f"#713: temporary_path = '{temporary_path}'")
logger.debug(f"\n#713: file listing:")
logger.debug(execute_command_and_capture_output(['ls', '-alR', f'{os.path.dirname(old_path)}'], capture_stderr=True, shell=True))
logger.debug(f"#713: os.path.isfile(old_path) = {os.path.isfile(old_path)}")
logger.debug(f"#713: os.path.isfile(temporary_path) = {os.path.isfile(temporary_path)}")
if not os.path.isfile(old_path) and not os.path.isfile(temporary_path):
logger.debug("#713: returning early")
return
logger.debug(f'Upgrading archives check time from {old_path} to {new_path}')
try:
os.rename(old_path, temporary_path)
except FileNotFoundError:
pass
except FileNotFoundError as error:
logger.debug(f"#713: FileNotFoundError: {error}")
logger.debug("#713: mkdir old path")
os.mkdir(old_path)
logger.debug("#713: rename temporary path to new path")
os.rename(temporary_path, new_path)
logger.debug("#713: end of loop")
logger.debug("#713: returning")
def check_archives(