diff --git a/engine/nsmservercontrol.py b/engine/nsmservercontrol.py index 07a981c..ed7a815 100644 --- a/engine/nsmservercontrol.py +++ b/engine/nsmservercontrol.py @@ -37,6 +37,7 @@ import subprocess import atexit import pathlib import json +from uuid import uuid4 from datetime import datetime from sys import exit as sysexit @@ -1362,8 +1363,11 @@ class NsmServerControl(object): logger.warning(f"Can't rename {nsmSessionName} to {newName}. {newName} already exists.") return False else: - logger.info(f"Renaming {nsmSessionName} to {newName}.") - oldPath.rename(newPath) + logger.info(f"Renaming {nsmSessionName} to {newName}.") + tmp = pathlib.Path(oldPath.name+str(uuid4())) #Can't move itself into a subdir in itself. move to temp first. We don't use tempdir because that could be on another partition. we already know we can write here. + oldPath.rename(tmp) + pathlib.Path(newPath).mkdir(parents=True, exist_ok=True) + tmp.rename(newPath) assert newPath.exists() def copySession(self, nsmSessionName:str, newName:str):