Browse Source

Protect against corner case where rename happens into a subdir of the session

master
Nils 4 years ago
parent
commit
2d89051867
  1. 8
      engine/nsmservercontrol.py

8
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):

Loading…
Cancel
Save