Skip to content

Commit a1d5929

Browse files
author
Martin Larralde
committed
Fix some errors not being raises in copy and move
1 parent 077c02e commit a1d5929

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

webdavfs/webdavfs.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import io
44
import six
55
import threading
6+
import operator
67
import logging
78

89
import webdav2.client as wc
@@ -238,7 +239,10 @@ def listdir(self, path):
238239
raise errors.DirectoryExpected(path)
239240

240241
dir_list = self.client.list(_path)
241-
return map(six.u, dir_list) if six.PY2 else dir_list
242+
if six.PY2:
243+
dir_list = map(operator.methodcaller('decode'), dir_list)
244+
245+
return list(map(operator.methodcaller('rstrip', '/'), dir_list))
242246

243247
def makedir(self, path, permissions=None, recreate=False):
244248
_path = self.validatepath(path)
@@ -312,6 +316,8 @@ def copy(self, src_path, dst_path, overwrite=False):
312316
_dst_path = self.validatepath(dst_path)
313317

314318
with self._lock:
319+
if not self.getinfo(_src_path).is_file:
320+
raise errors.FileExpected(src_path)
315321
if not overwrite and self.exists(_dst_path):
316322
raise errors.DestinationExists(dst_path)
317323
try:
@@ -325,6 +331,8 @@ def move(self, src_path, dst_path, overwrite=False):
325331
_src_path = self.validatepath(src_path)
326332
_dst_path = self.validatepath(dst_path)
327333

334+
if not self.getinfo(_src_path).is_file:
335+
raise errors.FileExpected(src_path)
328336
if not overwrite and self.exists(_dst_path):
329337
raise errors.DestinationExists(dst_path)
330338
with self._lock:

0 commit comments

Comments
 (0)