Use move rather than rename for trashing files on Linux

Move defaults to using rename under the hood but is more robust on
borked systems where trash is not on the same filesystem
This commit is contained in:
Kovid Goyal 2020-04-21 09:39:59 +05:30
parent 1e905098be
commit 96a77a59c4
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -21,6 +21,7 @@ from __future__ import absolute_import, division, print_function, unicode_litera
import os, stat
import os.path as op
from datetime import datetime
import shutil
from polyglot.builtins import unicode_type
from polyglot.urllib import quote
@ -89,7 +90,7 @@ def trash_move(src, dst, topdir=None):
check_create(filespath)
check_create(infopath)
os.rename(src, op.join(filespath, destname))
shutil.move(src, op.join(filespath, destname))
with open(op.join(infopath, destname + INFO_SUFFIX), 'wb') as f:
data = info_for(src, topdir)
if not isinstance(data, bytes):