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)
|
file_name = os.path.join(self.plcworkdir, file_name)
|
||||||
if os.path.exists(file_name):
|
if os.path.exists(file_name):
|
||||||
os.remove(file_name)
|
os.remove(file_name)
|
||||||
|
dirname = os.path.dirname(file_name)
|
||||||
|
if dirname != self.plcworkdir:
|
||||||
try:
|
try:
|
||||||
# Try to remove directory if empty
|
# Try to remove directory, which will work if it is empty
|
||||||
os.rmdir(os.path.dirname(file_name))
|
os.rmdir(dirname)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
return True
|
return True
|
||||||
@@ -1197,6 +1199,9 @@ class RevPiPyLoad:
|
|||||||
# Build absolut path, join will return last element, if absolute
|
# Build absolut path, join will return last element, if absolute
|
||||||
dirname = os.path.join(self.plcworkdir, os.path.dirname(filename))
|
dirname = os.path.join(self.plcworkdir, os.path.dirname(filename))
|
||||||
if os.path.abspath(dirname).find(self.plcworkdir) != 0:
|
if os.path.abspath(dirname).find(self.plcworkdir) != 0:
|
||||||
|
proginit.logger.warning(
|
||||||
|
"file path is not in plc working directory"
|
||||||
|
)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
set_uid = self.plcuid if self.plcworkdir_set_uid else 0
|
set_uid = self.plcuid if self.plcworkdir_set_uid else 0
|
||||||
|
|||||||
Reference in New Issue
Block a user