From cb4ec8cd398ce690231630acb59a41d1f84c9ec9 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 23 Dec 2011 22:13:24 +0530 Subject: [PATCH] Fix regression in 0.8.32 that broke deleting some books with non ascii characters in the title/author. Fixes #908068 (Error deleting ebooks with utf8 encode (calibre 0.8.32-linux)) --- src/calibre/utils/linux_trash.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/calibre/utils/linux_trash.py b/src/calibre/utils/linux_trash.py index 84d35d71b7..9c1559435b 100644 --- a/src/calibre/utils/linux_trash.py +++ b/src/calibre/utils/linux_trash.py @@ -36,6 +36,11 @@ uid = os.getuid() TOPDIR_TRASH = '.Trash' TOPDIR_FALLBACK = '.Trash-%s'%uid +def uniquote(raw): + if isinstance(raw, unicode): + raw = raw.encode('utf-8') + return quote(raw).decode('utf-8') + def is_parent(parent, path): path = op.realpath(path) # In case it's a symlink parent = op.realpath(parent) @@ -53,7 +58,7 @@ def info_for(src, topdir): src = op.relpath(src, topdir) info = "[Trash Info]\n" - info += "Path=" + quote(src) + "\n" + info += "Path=" + uniquote(src) + "\n" info += "DeletionDate=" + format_date(datetime.now()) + "\n" return info