Skip to content

Commit

Permalink
feature(study): normalize folder path using sqlachemy property
Browse files Browse the repository at this point in the history
  • Loading branch information
Anis SMAIL committed Jan 24, 2025
1 parent 99a5b82 commit 282fcd6
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions antarest/study/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ class Study(Base): # type: ignore
created_at = Column(DateTime, index=True)
updated_at = Column(DateTime, index=True)
last_access = Column(DateTime)
_path = Column(String())
folder = Column(String, nullable=True, index=True)
_path = Column("path", String)
_folder = Column("folder", String, nullable=True, index=True)
parent_id = Column(String(36), ForeignKey("study.id", name="fk_study_study_id"), index=True)
public_mode = Column(Enum(PublicMode), default=PublicMode.NONE)
owner_id = Column(Integer, ForeignKey(Identity.id), nullable=True, index=True)
Expand Down Expand Up @@ -294,10 +294,22 @@ def path(self):

@path.setter
def path(self, path: str):
windows_path = PureWindowsPath(path)
posix_path = windows_path.as_posix()
path_str = str(posix_path)
self._path = path_str
self._path = normalize_path(path)

@property
def folder(self):
return self._folder

@folder.setter
def folder(self, folder: str):
self._folder = normalize_path(folder)


def normalize_path(path: str) -> str:
if not path:
return path
windows_path = PureWindowsPath(path)
return windows_path.as_posix()


class RawStudy(Study):
Expand Down

0 comments on commit 282fcd6

Please sign in to comment.