tolerate windows trash errors

This commit is contained in:
Damien Elmes 2013-09-11 16:08:26 +09:00
parent bd8707f54c
commit f270d2f26e

View file

@ -35,6 +35,7 @@ FOF_ALLOWUNDO = 64
FOF_NOERRORUI = 1024 FOF_NOERRORUI = 1024
def send2trash(path): def send2trash(path):
opath = path
if not isinstance(path, unicode): if not isinstance(path, unicode):
path = unicode(path, u'mbcs') path = unicode(path, u'mbcs')
if not op.isabs(path): if not op.isabs(path):
@ -50,6 +51,7 @@ def send2trash(path):
fileop.lpszProgressTitle = None fileop.lpszProgressTitle = None
result = SHFileOperationW(byref(fileop)) result = SHFileOperationW(byref(fileop))
if result: if result:
msg = u"Couldn't perform operation. Error code: %d" % result # user's system is broken, just delete
raise OSError(msg) os.unlink(opath)
#msg = u"Couldn't perform operation. Error code: %d" % result
#raise OSError(msg)