Skip to content

Commit

Permalink
patch
Browse files Browse the repository at this point in the history
  • Loading branch information
lbr38 committed Sep 1, 2024
1 parent 75c934c commit 9d4ed70
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/controllers/Package/Apt.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,10 @@ def parse_history(self, history_files: list, entries_limit: int):

# Parse each apt history files
for history_file in history_files:
# If file is empty (e.g. file has been rotated), ignore it
if os.stat(history_file).st_size == 0:
continue

# Retrieve all Start-Date in the history file
result = subprocess.run(
['zgrep "^Start-Date:*" ' + history_file],
Expand All @@ -362,7 +366,7 @@ def parse_history(self, history_files: list, entries_limit: int):

# Quit if an error occurred
if result.returncode != 0:
raise Exception('could not retrieve Start-Date from ' + history_file + ': ' + result.stderr)
raise Exception('no result matching the pattern "Start-Date" in file ' + history_file)

# Split the result into a list
start_dates = result.stdout.strip().split('\n')
Expand Down Expand Up @@ -408,7 +412,7 @@ def parse_history(self, history_files: list, entries_limit: int):
)

if result.returncode != 0:
raise Exception('could not retrieve event for ' + start_date + ' in ' + history_file + ': ' + result.stderr)
raise Exception('no event found for date "' + start_date + '" in file ' + history_file)

# Retrieve event block lines
event = result.stdout.strip()
Expand Down

0 comments on commit 9d4ed70

Please sign in to comment.