mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
snapshot: Improved messages and minor refactoring
- Make the default snapshot detection slightly more robust and refactor. - Expand description to explain automatic snapshotting, etc. - Show description even after setup. - Show default snapshot as a bootstrap label. - Message explaing how rollback can be undone. - Minor updates to delete/rollback confirmation messages. - Minor style refactoring
This commit is contained in:
6 files changed
+102
-71
No files matched your search
+17
-7
@@ -85,17 +85,27 @@ def subcommand_list(_):
|
||||
parts = [part.strip() for part in line.split('|')]
|
||||
snapshots.append(dict(zip(keys, parts)))
|
||||
|
||||
# Mark default subvolume.
|
||||
default = _get_default_snapshot()
|
||||
for snapshot in snapshots:
|
||||
snapshot['is_default'] = (snapshot['number'] == default)
|
||||
|
||||
print(json.dumps(snapshots))
|
||||
|
||||
|
||||
def _get_default_snapshot():
|
||||
"""Return the default snapshot by looking at default subvolume."""
|
||||
command = ['btrfs', 'subvolume', 'get-default', '/']
|
||||
process = subprocess.run(command, stdout=subprocess.PIPE, check=True)
|
||||
output = process.stdout.decode()
|
||||
default = None
|
||||
if '.snapshots' in output:
|
||||
default = output.split('/')[1]
|
||||
for snapshot in snapshots:
|
||||
snapshot['is_default'] = snapshot['number'] == default
|
||||
|
||||
print(json.dumps(snapshots))
|
||||
output_parts = output.split()
|
||||
if len(output_parts) >= 9:
|
||||
path = output.split()[8]
|
||||
path_parts = path.split('/')
|
||||
if len(path_parts) == 3 and path_parts[0] == '.snapshots':
|
||||
return path_parts[1]
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def subcommand_create(_):
|
||||
|
||||
Reference in new issue
Block a user