Skip to content

Commit 7ac1c76

Browse files
committed
Improved deleting old be
1 parent a378190 commit 7ac1c76

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# to update i18n .mo files (and merge .pot file into .po files) run on Linux:
1212
# python setup.py build_i18n -m''
1313

14-
__VERSION__ = '6.2'
14+
__VERSION__ = '6.3'
1515

1616
PROGRAM_VERSION = __VERSION__
1717
prefix = sys.prefix

update_station/frontend.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,38 @@ def __init__(self):
251251
self.thr = threading.Thread(target=self.read_output, args=[self.pbar], daemon=True)
252252
self.thr.start()
253253

254+
@classmethod
255+
def should_destroy_be(cls, be_line: str, today_str: str) -> bool:
256+
"""
257+
Determines if a Boot Environment should be destroyed based on criteria.
258+
Returns False if the BE is protected (active and mounted at root).
259+
:param be_line: The BE line to check.
260+
:param today_str: The string representation of today's date.
261+
:return: True if the BE should be destroyed, False otherwise.
262+
"""
263+
# Split the line into columns, handling multiple spaces
264+
columns = be_line.split()
265+
if len(columns) < 4:
266+
return False
267+
268+
be_name = columns[0]
269+
active_status = columns[1]
270+
mount_point = columns[2]
271+
272+
# Protect BE if it's active (N) AND mounted at root (/)
273+
if 'N' in active_status and mount_point == '/':
274+
return False
275+
276+
if 'R' in active_status:
277+
return False
278+
279+
# Apply your original deletion criteria
280+
return (
281+
'backup' in be_name and
282+
today_str not in be_name and
283+
'NR' not in active_status
284+
)
285+
254286

255287
def read_output(self, progress):
256288
"""
@@ -280,7 +312,7 @@ def read_output(self, progress):
280312
txt = _("Cleaning old boot environment")
281313
GLib.idle_add(update_progress, progress, fraction, txt)
282314
for be in bectl.get_be_list():
283-
if 'backup' in be and today not in be and 'NR' not in be:
315+
if self.should_destroy_be(be, today):
284316
bectl.destroy_be(be.split()[0])
285317
backup_name = datetime.datetime.now().strftime(f"{distro.version()}-backup-%Y-%m-%d-%H-%M")
286318
txt = _("Creating boot environment")

0 commit comments

Comments
 (0)