fix bug in get_latest_session_id when dir didnt exist
This commit is contained in:
parent
18d9782a8a
commit
1c2a957f99
1 changed files with 7 additions and 1 deletions
|
|
@ -80,7 +80,13 @@ class DirManager:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_latest_session_id(output_dir: Path) -> Optional[str]:
|
def get_latest_session_id(output_dir: Path) -> Optional[str]:
|
||||||
"""returns the name of the newest dir inside of output_dir"""
|
"""returns the name of the newest dir inside of output_dir
|
||||||
|
|
||||||
|
if output_dir does not exists or is empty, None is returned"""
|
||||||
|
|
||||||
|
if not output_dir.is_dir():
|
||||||
|
return None
|
||||||
|
|
||||||
all_dirs = [d for d in output_dir.iterdir() if d.is_dir()]
|
all_dirs = [d for d in output_dir.iterdir() if d.is_dir()]
|
||||||
if all_dirs:
|
if all_dirs:
|
||||||
newest_dir: Path = max(all_dirs, key=lambda x: x.stat().st_ctime)
|
newest_dir: Path = max(all_dirs, key=lambda x: x.stat().st_ctime)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue