Skip to content

Commit

Permalink
perf: increase the judgment on creating folders
Browse files Browse the repository at this point in the history
  • Loading branch information
RamidLab committed Aug 11, 2023
1 parent ecbb692 commit 7306a03
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions owncloud/owncloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,17 @@ def mkdir(self, path):
"""
if not path.endswith('/'):
path += '/'

path_split = list(filter(None, path.split("/")))
if len(path_split) > 1:
file_list = [x.get_name() for x in self.list(self._normalize_path("/".join(path_split[0:-1])))]
if path_split[-1] in file_list:
raise FileExistsError(f"Remote folder {path_split[-1]} exist, please check!")
else:
file_list = [x.get_name() for x in self.list(path="./")]
if path_split[0] in file_list:
raise FileExistsError(f"Remote folder {path_split[-1]} exist, please check!")

return self._make_dav_request('MKCOL', path)

def delete(self, path):
Expand Down

0 comments on commit 7306a03

Please sign in to comment.