Skip to content

Commit 0d1d624

Browse files
author
Scott Wales
committedDec 15, 2020
Ignore existing directories
1 parent 7c8af42 commit 0d1d624

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed
 

‎cloudstor

+9-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def curl_command(cmd, target):
3232

3333
root = ET.fromstring(r.stdout)
3434
if root.tag == '{DAV:}error':
35-
raise DAVException(root.find('{http://sabredav.org/ns}message').text + ': ' + target)
35+
raise DAVException(root.find('{http://sabredav.org/ns}message').text, target)
3636

3737
return root
3838

@@ -56,7 +56,13 @@ def mkdir(target):
5656
Make a directory 'target'
5757
"""
5858
print("MKDIR",target)
59-
curl_command(['-X','MKCOL'], target)
59+
try:
60+
curl_command(['-X','MKCOL'], target)
61+
except DAVException as e:
62+
if e.args[0] == 'The resource you tried to create already exists':
63+
pass
64+
else:
65+
raise
6066

6167

6268
def put_recursive(path, target):
@@ -88,7 +94,7 @@ def main():
8894

8995
sub_mkdir = subp.add_parser('mkdir', help="Make directory")
9096
sub_mkdir.add_argument("target")
91-
sub_mkdir.set_defaults(func=put)
97+
sub_mkdir.set_defaults(func=mkdir)
9298

9399
args = parser.parse_args()
94100

0 commit comments

Comments
 (0)
Please sign in to comment.