Skip to content

Commit 7306a03

Browse files
committed
perf: increase the judgment on creating folders
1 parent ecbb692 commit 7306a03

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

owncloud/owncloud.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,17 @@ def mkdir(self, path):
718718
"""
719719
if not path.endswith('/'):
720720
path += '/'
721+
722+
path_split = list(filter(None, path.split("/")))
723+
if len(path_split) > 1:
724+
file_list = [x.get_name() for x in self.list(self._normalize_path("/".join(path_split[0:-1])))]
725+
if path_split[-1] in file_list:
726+
raise FileExistsError(f"Remote folder {path_split[-1]} exist, please check!")
727+
else:
728+
file_list = [x.get_name() for x in self.list(path="./")]
729+
if path_split[0] in file_list:
730+
raise FileExistsError(f"Remote folder {path_split[-1]} exist, please check!")
731+
721732
return self._make_dav_request('MKCOL', path)
722733

723734
def delete(self, path):

0 commit comments

Comments
 (0)