mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
fall back on regular delete on broken recycle bin (#926)
This commit is contained in:
parent
2047e5c93c
commit
64c4f1974b
2 changed files with 16 additions and 0 deletions
8
thirdparty/send2trash/plat_osx.py
vendored
8
thirdparty/send2trash/plat_osx.py
vendored
|
@ -6,6 +6,7 @@
|
|||
|
||||
from ctypes import cdll, byref, Structure, c_char, c_char_p
|
||||
from ctypes.util import find_library
|
||||
import os
|
||||
|
||||
Foundation = cdll.LoadLibrary(find_library(u'Foundation'))
|
||||
CoreServices = cdll.LoadLibrary(find_library(u'CoreServices'))
|
||||
|
@ -33,6 +34,13 @@ def check_op_result(op_result):
|
|||
raise OSError(msg)
|
||||
|
||||
def send2trash(path):
|
||||
try:
|
||||
_send2trash(path)
|
||||
except OSError:
|
||||
# user's system is broken; just delete
|
||||
os.unlink(path)
|
||||
|
||||
def _send2trash(path):
|
||||
if not isinstance(path, str):
|
||||
path = path.encode(u'utf-8')
|
||||
fp = FSRef()
|
||||
|
|
8
thirdparty/send2trash/plat_other.py
vendored
8
thirdparty/send2trash/plat_other.py
vendored
|
@ -129,6 +129,13 @@ def get_dev(path):
|
|||
return os.lstat(path).st_dev
|
||||
|
||||
def send2trash(path):
|
||||
try:
|
||||
_send2trash(path)
|
||||
except OSError:
|
||||
# user's system is broken; just delete
|
||||
os.unlink(path)
|
||||
|
||||
def _send2trash(path):
|
||||
if not isinstance(path, unicode):
|
||||
path = unicode(path, sys.getfilesystemencoding())
|
||||
if not op.exists(path):
|
||||
|
@ -155,3 +162,4 @@ def send2trash(path):
|
|||
raise OSError(u"Couldn't find mount point for %s" % path)
|
||||
dest_trash = find_ext_volume_trash(topdir)
|
||||
trash_move(path, dest_trash, topdir)
|
||||
|
||||
|
|
Loading…
Reference in a new issue