#1714: apply suggestions for preventing addition of objects with similar uuid
This commit is contained in:
@@ -95,7 +95,13 @@ class FileSystem(SimComponent):
|
||||
:type: folder_name: str
|
||||
"""
|
||||
folder = FileSystemFolder(name=folder_name)
|
||||
self.folders[folder.uuid] = folder
|
||||
|
||||
if folder.uuid in self.folders:
|
||||
# iterate until a folder with a non-matching uuid is added
|
||||
# which is VERY unlikely but it'll be weird if it happens twice
|
||||
return self.create_folder(folder_name=folder_name)
|
||||
else:
|
||||
self.folders[folder.uuid] = folder
|
||||
return folder
|
||||
|
||||
def delete_file(self, file: Optional[FileSystemFile] = None):
|
||||
|
||||
@@ -26,7 +26,7 @@ class FileSystemFolder(FileSystemItem):
|
||||
raise Exception(f"Invalid file: {file}")
|
||||
|
||||
# check if file with id already exists in folder
|
||||
if self.get_file_by_id(file.uuid) is not None:
|
||||
if file.uuid in self.files:
|
||||
_LOGGER.debug(f"File with id {file.uuid} already exists in folder")
|
||||
else:
|
||||
# add to list
|
||||
|
||||
Reference in New Issue
Block a user