From 5a9097f5c014290dcffdce45d88783eaefe29230 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 18 Feb 2011 14:05:36 -0700 Subject: [PATCH] ... --- src/calibre/libunrar.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/calibre/libunrar.py b/src/calibre/libunrar.py index d0e48034b5..2cebd40a79 100644 --- a/src/calibre/libunrar.py +++ b/src/calibre/libunrar.py @@ -270,18 +270,21 @@ def extract_member(path, match=re.compile(r'\.(jpg|jpeg|gif|png)\s*$', re.I), return path, open(path, 'rb').read() def extract_first_alphabetically(path): + remove_path = False if hasattr(path, 'read'): data = path.read() with PersistentTemporaryFile('.rar') as f: f.write(data) path = f.name + remove_path = True names_ = [x for x in names(path) if os.path.splitext(x)[1][1:].lower() in ('png', 'jpg', 'jpeg', 'gif')] names_.sort() ans = extract_member(path, name=names_[0], match=None) try: - os.remove(path) + if remove_path: + os.remove(path) except: pass return ans