Add symlink check to test API endpoint
This commit is contained in:
1 parent
68f67219ed
commit
654055da61
1 file changed
+13
-7
@@ -292,14 +292,20 @@ def _test_path(data):
|
||||
|
||||
# check if path exists
|
||||
exists = os.path.exists(path)
|
||||
if not exists and check_type == "dir" and allow_create_dir:
|
||||
try:
|
||||
os.makedirs(path)
|
||||
except:
|
||||
logging.getLogger(__name__).exception("Error while trying to create {}".format(path))
|
||||
if not exists:
|
||||
if os.path.islink(path):
|
||||
# broken symlink, see #2644
|
||||
logging.getLogger(__name__).error("{} is a broken symlink")
|
||||
return jsonify(path=path, exists=False, typeok=False, access=False, result=False)
|
||||
else:
|
||||
exists = True
|
||||
|
||||
elif check_type == "dir" and allow_create_dir:
|
||||
try:
|
||||
os.makedirs(path)
|
||||
except:
|
||||
logging.getLogger(__name__).exception("Error while trying to create {}".format(path))
|
||||
return jsonify(path=path, exists=False, typeok=False, access=False, result=False)
|
||||
else:
|
||||
exists = True
|
||||
|
||||
# check path type
|
||||
type_mapping = dict(file=os.path.isfile, dir=os.path.isdir)
|
||||
|
||||
Reference in new issue
Block a user