Fix currentUpload() return value

This commit is contained in:
Kumi 2021-11-26 07:52:16 +01:00
parent 25844a1f59
commit e62af0f71f

View file

@ -52,7 +52,7 @@ class Vessel:
if "Address" in config.keys():
return cls(config.name.split()[1], config["Address"], username,
password, passphrase, tempdir)
password, passphrase, tempdir)
else:
raise ValueError("Definition for Vessel " +
config.name.split()[1] + " does not contain Address!")
@ -107,17 +107,20 @@ class Vessel:
db = Database()
return db.getCompletionForVessel(self)
def currentUpload(self) -> File:
def currentUpload(self) -> Optional[File]:
"""Get the File that is currently being uploaded to this Vessel
Returns:
classes.file.File: File object representing the file currently
being uploaded
being uploaded, if any
"""
db = Database()
directory, name, _ = db.getFileByUUID(
output = db.getFileByUUID(
fileuuid := self.connection.getCurrentUploadUUID())
return File(name, directory, fileuuid)
if output:
directory, name, _ = output
return File(name, directory, fileuuid)
def clearTempDir(self) -> None:
"""Clean up the temporary directory on the Vessel