mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-02-02 14:16:38 +00:00
fix(storage): fix root device detection and ignore iso9660
This commit is contained in:
parent
829915029d
commit
641ab26069
|
@ -23,7 +23,7 @@ class Storage:
|
||||||
else str(volume.size),
|
else str(volume.size),
|
||||||
free_space=str(volume.fsavail),
|
free_space=str(volume.fsavail),
|
||||||
used_space=str(volume.fsused),
|
used_space=str(volume.fsused),
|
||||||
root=volume.name == "sda1",
|
root=volume.is_root(),
|
||||||
name=volume.name,
|
name=volume.name,
|
||||||
model=volume.model,
|
model=volume.model,
|
||||||
serial=volume.serial,
|
serial=volume.serial,
|
||||||
|
|
|
@ -83,7 +83,7 @@ def move_service(
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
# Make sure the volume is mounted
|
# Make sure the volume is mounted
|
||||||
if volume.name != "sda1" and f"/volumes/{volume.name}" not in volume.mountpoints:
|
if not volume.is_root() and f"/volumes/{volume.name}" not in volume.mountpoints:
|
||||||
Jobs.update(
|
Jobs.update(
|
||||||
job=job,
|
job=job,
|
||||||
status=JobStatus.ERROR,
|
status=JobStatus.ERROR,
|
||||||
|
|
|
@ -71,6 +71,12 @@ class BlockDevice:
|
||||||
def __hash__(self):
|
def __hash__(self):
|
||||||
return hash(self.name)
|
return hash(self.name)
|
||||||
|
|
||||||
|
def is_root(self) -> bool:
|
||||||
|
"""
|
||||||
|
Return True if the block device is the root device.
|
||||||
|
"""
|
||||||
|
return "/" in self.mountpoints
|
||||||
|
|
||||||
def stats(self) -> typing.Dict[str, typing.Any]:
|
def stats(self) -> typing.Dict[str, typing.Any]:
|
||||||
"""
|
"""
|
||||||
Update current data and return a dictionary of stats.
|
Update current data and return a dictionary of stats.
|
||||||
|
@ -175,6 +181,9 @@ class BlockDevices(metaclass=SingletonMetaclass):
|
||||||
# Ignore devices with type "rom"
|
# Ignore devices with type "rom"
|
||||||
if device["type"] == "rom":
|
if device["type"] == "rom":
|
||||||
continue
|
continue
|
||||||
|
# Ignore iso9660 devices
|
||||||
|
if device["fstype"] == "iso9660":
|
||||||
|
continue
|
||||||
if device["fstype"] is None:
|
if device["fstype"] is None:
|
||||||
if "children" in device:
|
if "children" in device:
|
||||||
for child in device["children"]:
|
for child in device["children"]:
|
||||||
|
|
Loading…
Reference in a new issue