mirror of
https://github.com/naruxde/revpipyload.git
synced 2025-11-08 15:13:52 +01:00
Bugfix - Do not remove empty plcworkdir on xml_plcdelete_file function
This commit is contained in:
@@ -1078,9 +1078,11 @@ class RevPiPyLoad:
|
||||
file_name = os.path.join(self.plcworkdir, file_name)
|
||||
if os.path.exists(file_name):
|
||||
os.remove(file_name)
|
||||
dirname = os.path.dirname(file_name)
|
||||
if dirname != self.plcworkdir:
|
||||
try:
|
||||
# Try to remove directory if empty
|
||||
os.rmdir(os.path.dirname(file_name))
|
||||
# Try to remove directory, which will work if it is empty
|
||||
os.rmdir(dirname)
|
||||
except Exception:
|
||||
pass
|
||||
return True
|
||||
@@ -1197,6 +1199,9 @@ class RevPiPyLoad:
|
||||
# Build absolut path, join will return last element, if absolute
|
||||
dirname = os.path.join(self.plcworkdir, os.path.dirname(filename))
|
||||
if os.path.abspath(dirname).find(self.plcworkdir) != 0:
|
||||
proginit.logger.warning(
|
||||
"file path is not in plc working directory"
|
||||
)
|
||||
return False
|
||||
|
||||
set_uid = self.plcuid if self.plcworkdir_set_uid else 0
|
||||
|
||||
Reference in New Issue
Block a user