From 96a77a59c43acc86a1aa6a12f780dc8a5bd91378 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 21 Apr 2020 09:39:59 +0530 Subject: [PATCH] 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 --- src/calibre/utils/linux_trash.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/calibre/utils/linux_trash.py b/src/calibre/utils/linux_trash.py index 2de771224d..558c9aa779 100644 --- a/src/calibre/utils/linux_trash.py +++ b/src/calibre/utils/linux_trash.py @@ -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):