Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions aas_editor/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,23 @@ def name(self):
else:
return f"/{self._filePath.name}"

@name.setter
def name(self, new_name: str):
if not isinstance(new_name, str) or new_name.strip() == "":
raise TypeError("new name must be a non-empty string")

if self.savedInStore():
new_stored_name = self._fileStore.rename_file(self.name, new_name)
self._name = new_stored_name
else:
if self._filePath is None:
raise ValueError("No local file path available to rename")
new_path = self._filePath.parent.joinpath(new_name)
if new_path.exists():
raise FileExistsError(f"Target file already exists: {new_path}")
self._filePath.rename(new_path)
self._filePath = new_path

@property
def mime_type(self) -> str:
if self.savedInStore():
Expand Down