Skip to content

Commit

Permalink
Fix for type in cleanup.py
Browse files Browse the repository at this point in the history
Signed-off-by: Damien Thenot <[email protected]>
  • Loading branch information
Nambrok committed Jan 16, 2025
1 parent a42a93c commit 67ab1cd
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions drivers/cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -791,10 +791,7 @@ def __str__(self) -> str:
strSizeAllocated = "?"
if self._sizeAllocated >= 0:
strSizeAllocated = "/%s" % Util.num2str(self._sizeAllocated)
strType = ""
if self.vdi_type == VdiType.RAW:
strType = "[RAW]"
strSizePhys = ""
strType = "[{}]".format(self.vdi_type)

return "%s%s(%s%s%s)%s" % (strHidden, self.uuid[0:8], strSizeVirt,
strSizePhys, strSizeAllocated, strType)
Expand Down Expand Up @@ -1138,14 +1135,8 @@ class FileVDI(VDI):

@staticmethod
def extractUuid(path):
path = os.path.basename(path.strip())
if not (path.endswith(VdiTypeExtension.VHD) or \
path.endswith(VdiTypeExtension.RAW)):
return None
uuid = path.replace(VdiTypeExtension.VHD, "").replace( \
VdiTypeExtension.RAW, "")
# TODO: validate UUID format
return uuid
fileName = os.path.basename(path)
return os.path.splitext(fileName)[0]

def __init__(self, sr, uuid, vdi_type):
VDI.__init__(self, sr, uuid, vdi_type)
Expand All @@ -1170,13 +1161,13 @@ def load(self, info=None) -> None:
self.hidden = info.hidden
self.scanError = False
self.path = os.path.join(self.sr.path, "%s%s" % \
(self.uuid, VdiTypeExtension.VHD))
(self.uuid, VDI_TYPE_TO_EXTENSION[self.vdi_type]))

@override
def rename(self, uuid) -> None:
oldPath = self.path
VDI.rename(self, uuid)
self.fileName = "%s%s" % (self.uuid, VdiTypeExtension.VHD)
self.fileName = "%s%s" % (self.uuid, VDI_TYPE_TO_EXTENSION[self.vdi_type])
self.path = os.path.join(self.sr.path, self.fileName)
assert(not util.pathexists(self.path))
Util.log("Renaming %s -> %s" % (oldPath, self.path))
Expand Down

0 comments on commit 67ab1cd

Please sign in to comment.