diff --git a/tests/test_backup.py b/tests/test_backup.py index f46a355b764461b22af15e8bdcc50896421e8521..1f7e3faf1d950a4c9c3c2da0c5ebc0fc859b34f4 100755 --- a/tests/test_backup.py +++ b/tests/test_backup.py @@ -70,22 +70,24 @@ def test_backup_space(server): def check_local_backup(path): all_ok = True for d in os.listdir(path): - subd = os.path.join(path, d) - latest = os.path.join(subd, 'latest') - if os.path.exists(latest): - mtime = os.path.getmtime(latest) - d = datetime.fromtimestamp(mtime) - now = datetime.now() - diff_seconds = (now - d).total_seconds() - if diff_seconds > 25*3600: - print('Backup %s is older than a day' % subd) - all_ok = False + if os.path.isdir(d): + subd = os.path.join(path, d) + latest = os.path.join(subd, 'latest') + if os.path.exists(latest): + mtime = os.path.getmtime(latest) + d = datetime.fromtimestamp(mtime) + now = datetime.now() + diff_seconds = (now - d).total_seconds() + if diff_seconds > 25*3600: + print('Backup %s is older than a day' % subd) + all_ok = False + else: + print('Backup %s is fine' % subd) else: - print('Backup %s is fine' % subd) - else: - for dd in os.listdir(subd): - subsubd = os.path.join(subd, dd) - all_ok = min(all_ok, check_local_backup(subsubd)) + for dd in os.listdir(subd): + if os.path.isdir(dd): + subsubd = os.path.join(subd, dd) + all_ok = min(all_ok, check_local_backup(subsubd)) return all_ok