1616except ImportError :
1717 from urllib import unquote
1818
19- __version__ = "1.0.7 "
19+ __version__ = "1.0.8 "
2020
2121
2222def listdir (directory ):
@@ -71,7 +71,7 @@ class Client(object):
7171 'move' : ["Accept: */*" ],
7272 'mkdir' : ["Accept: */*" , "Connection: Keep-Alive" ],
7373 'clean' : ["Accept: */*" , "Connection: Keep-Alive" ],
74- 'check' : ["Accept: */*" , "Depth: 0" ],
74+ 'check' : ["Accept: */*" ],
7575 'info' : ["Accept: */*" , "Depth: 1" ],
7676 'get_metadata' : ["Accept: */*" , "Depth: 1" , "Content-Type: application/x-www-form-urlencoded" ],
7777 'set_metadata' : ["Accept: */*" , "Depth: 1" , "Content-Type: application/x-www-form-urlencoded" ]
@@ -98,7 +98,7 @@ def get_header(self, method):
9898 'move' : "MOVE" ,
9999 'mkdir' : "MKCOL" ,
100100 'clean' : "DELETE" ,
101- 'check' : "PROPFIND " ,
101+ 'check' : "HEAD " ,
102102 'list' : "PROPFIND" ,
103103 'free' : "PROPFIND" ,
104104 'info' : "PROPFIND" ,
@@ -164,6 +164,15 @@ def Request(self, options=None):
164164 if self .webdav .key_path :
165165 self .default_options ['SSLKEY' ] = self .webdav .key_path
166166
167+ if self .webdav .recv_speed :
168+ self .default_options ['MAX_RECV_SPEED_LARGE' ] = self .webdav .recv_speed
169+
170+ if self .webdav .send_speed :
171+ self .default_options ['MAX_SEND_SPEED_LARGE' ] = self .webdav .send_speed
172+
173+ if self .webdav .verbose :
174+ self .default_options ['VERBOSE' ] = self .webdav .verbose
175+
167176 if self .default_options :
168177 add_options (curl , self .default_options )
169178
@@ -266,52 +275,29 @@ def data():
266275
267276 def check (self , remote_path = root ):
268277
269- def parse (response , path ):
270-
271- try :
272- response_str = response .getvalue ()
273- tree = etree .fromstring (response_str )
274-
275- resps = tree .findall ("{DAV:}response" )
276-
277- for resp in resps :
278- href = resp .findtext ("{DAV:}href" )
279- urn = unquote (href )
280-
281- if path .endswith (Urn .separate ):
282- if path == urn or path [:- 1 ] == urn :
283- return True
284- else :
285- if path == urn :
286- return True
287-
288- return False
289-
290- except etree .XMLSyntaxError :
291- return False
292-
293278 try :
294279 urn = Urn (remote_path )
295- parent_urn = Urn (urn .parent ())
296280 response = BytesIO ()
297281
298- url = {'hostname' : self .webdav .hostname , 'root' : self .webdav .root , 'path' : parent_urn .quote ()}
282+ url = {'hostname' : self .webdav .hostname , 'root' : self .webdav .root , 'path' : urn .quote ()}
299283 options = {
300284 'URL' : "{hostname}{root}{path}" .format (** url ),
301- 'CUSTOMREQUEST' : Client .requests ['info ' ],
302- 'HTTPHEADER' : self .get_header ('info ' ),
285+ 'CUSTOMREQUEST' : Client .requests ['check ' ],
286+ 'HTTPHEADER' : self .get_header ('check ' ),
303287 'WRITEDATA' : response ,
304- 'NOBODY' : 0
288+ 'NOBODY' : 1
305289 }
306290
307291 request = self .Request (options = options )
308292
309293 request .perform ()
294+ code = request .getinfo (pycurl .HTTP_CODE )
310295 request .close ()
311296
312- path = "{root}{path}" .format (root = self .webdav .root , path = urn .path ())
313-
314- return parse (response , path )
297+ if int (code ) == 200 :
298+ return True
299+
300+ return False
315301
316302 except pycurl .error :
317303 raise NotConnection (self .webdav .hostname )
@@ -514,9 +500,6 @@ def upload_file(self, remote_path, local_path, progress=None):
514500 if os .path .isdir (local_path ):
515501 raise OptionNotValid (name = "local_path" , value = local_path )
516502
517- if not os .path .exists (local_path ):
518- raise LocalResourceNotFound (local_path )
519-
520503 if not self .check (urn .parent ()):
521504 raise RemoteParentNotFound (urn .path ())
522505
0 commit comments