mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
storage: Ignore eject failures if filesystems unmounted properly
Not all disks can be ejected. For example, SATA disks can't be ejected. However, they can be removed as long as all filesystems are unmounted properly. Ignore errors during ejecting of a disk. Closes: #1597. Tests performed: - In VirtualBox, attach a SATA disk, format it with two partitions. See them auto-mounted by FreedomBox. Eject one of the partitions, both partitions are unmounted but operation does not fail despite SATA disks not being eject-able. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
d3b5143ed6
commit
e59f9ac3fc
@ -281,6 +281,7 @@ def eject_drive_of_device(device_path):
|
||||
Return the details (model, vendor) of drives ejected.
|
||||
"""
|
||||
udisks = utils.import_from_gi('UDisks', '2.0')
|
||||
glib = utils.import_from_gi('GLib', '2.0')
|
||||
client = udisks.Client.new_sync()
|
||||
object_manager = client.get_object_manager()
|
||||
|
||||
@ -307,7 +308,13 @@ def eject_drive_of_device(device_path):
|
||||
# Eject the drive
|
||||
drive = client.get_drive_for_block(block_device)
|
||||
if drive:
|
||||
drive.call_eject_sync(_get_options(), None)
|
||||
try:
|
||||
drive.call_eject_sync(_get_options(), None)
|
||||
except glib.Error:
|
||||
# Ignore error during ejection as along as all the filesystems are
|
||||
# unmounted, the disk can be removed.
|
||||
pass
|
||||
|
||||
return {
|
||||
'vendor': drive.props.vendor,
|
||||
'model': drive.props.model,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user