Commit de98e4d8 by rfkelly0

support for ResourceLockedError on Windows

parent c0896558
...@@ -144,6 +144,11 @@ def convert_fs_errors(func): ...@@ -144,6 +144,11 @@ def convert_fs_errors(func):
raise OSError(errno.EINVAL,str(e)) raise OSError(errno.EINVAL,str(e))
except PermissionDeniedError, e: except PermissionDeniedError, e:
raise OSError(errno.EACCES,str(e)) raise OSError(errno.EACCES,str(e))
except ResourceLockedError, e:
if sys.platform == "win32":
raise WindowsError(32,str(e))
else:
raise OSError(errno.EACCES,str(e))
except DirectoryNotEmptyError, e: except DirectoryNotEmptyError, e:
raise OSError(errno.ENOTEMPTY,str(e)) raise OSError(errno.ENOTEMPTY,str(e))
except DestinationExistsError, e: except DestinationExistsError, e:
...@@ -194,6 +199,9 @@ def convert_os_errors(func): ...@@ -194,6 +199,9 @@ def convert_os_errors(func):
if e.errno == errno.ENOSPC: if e.errno == errno.ENOSPC:
raise StorageSpaceError(opname,details=e),None,tb raise StorageSpaceError(opname,details=e),None,tb
if e.errno == errno.EACCES: if e.errno == errno.EACCES:
if sys.platform == "win32":
if e.args[0] and e.args[0] == 32:
raise ResourceLockedError(path,opname=opname,details=e),None,tb
raise PermissionDeniedError(opname,details=e),None,tb raise PermissionDeniedError(opname,details=e),None,tb
# Sometimes windows gives some random errors... # Sometimes windows gives some random errors...
if sys.platform == "win32": if sys.platform == "win32":
......
...@@ -349,7 +349,7 @@ class MemoryFS(FS): ...@@ -349,7 +349,7 @@ class MemoryFS(FS):
if dir_entry.islocked(): if dir_entry.islocked():
self._orphan_files(dir_entry) self._orphan_files(dir_entry)
#raise ResourceLockedError("FILE_LOCKED", path) #raise ResourceLockedError(path)
if dir_entry.isdir(): if dir_entry.isdir():
raise ResourceInvalidError(path,msg="That's a directory, not a file: %(path)s") raise ResourceInvalidError(path,msg="That's a directory, not a file: %(path)s")
...@@ -397,7 +397,7 @@ class MemoryFS(FS): ...@@ -397,7 +397,7 @@ class MemoryFS(FS):
if dir_entry is None: if dir_entry is None:
raise ResourceNotFoundError(src) raise ResourceNotFoundError(src)
#if dir_entry.islocked(): #if dir_entry.islocked():
# raise ResourceLockedError("FILE_LOCKED", src) # raise ResourceLockedError(src)
open_files = dir_entry.open_files[:] open_files = dir_entry.open_files[:]
for f in open_files: for f in open_files:
......
...@@ -4,6 +4,8 @@ import os ...@@ -4,6 +4,8 @@ import os
from osfs import OSFS from osfs import OSFS
import tempfile import tempfile
from fs.errors import *
class TempFS(OSFS): class TempFS(OSFS):
"""Create a Filesystem in a tempory directory (with tempfile.mkdtemp), """Create a Filesystem in a tempory directory (with tempfile.mkdtemp),
...@@ -28,6 +30,7 @@ class TempFS(OSFS): ...@@ -28,6 +30,7 @@ class TempFS(OSFS):
def __unicode__(self): def __unicode__(self):
return unicode(self.__str__()) return unicode(self.__str__())
@convert_os_errors
def close(self): def close(self):
"""Removes the temporary directory. """Removes the temporary directory.
This will be called automatically when the object is cleaned up by This will be called automatically when the object is cleaned up by
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment