From 0735fb1e929fd673397acdd7e2c1c8be0d510d3f Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Tue, 5 May 2020 18:55:28 +0200 Subject: [PATCH] Fix #1349 (Fix error on move cover with foreign file systems, e.g. samba shares) Preparation for release --- cps/constants.py | 2 +- cps/editbooks.py | 23 ++++++----- test/Calibre-Web TestSummary.html | 66 ++++++++++++++++--------------- 3 files changed, 48 insertions(+), 43 deletions(-) mode change 100644 => 100755 test/Calibre-Web TestSummary.html diff --git a/cps/constants.py b/cps/constants.py index 586172f7..4de6b7a1 100644 --- a/cps/constants.py +++ b/cps/constants.py @@ -129,7 +129,7 @@ def selected_roles(dictionary): BookMeta = namedtuple('BookMeta', 'file_path, extension, title, author, cover, description, tags, series, ' 'series_id, languages') -STABLE_VERSION = {'version': '0.6.7 Beta'} +STABLE_VERSION = {'version': '0.6.7'} NIGHTLY_VERSION = {} NIGHTLY_VERSION[0] = '$Format:%H$' diff --git a/cps/editbooks.py b/cps/editbooks.py index 2204ce1e..d6b18f93 100644 --- a/cps/editbooks.py +++ b/cps/editbooks.py @@ -702,16 +702,11 @@ def upload(): return Response(json.dumps({"location": url_for("web.index")}), mimetype='application/json') try: copyfile(meta.file_path, saved_filename) - except OSError: - log.error("Failed to store file %s (Permission denied)", saved_filename) - flash(_(u"Failed to store file %(file)s (Permission denied).", file=saved_filename), category="error") - return Response(json.dumps({"location": url_for("web.index")}), mimetype='application/json') - try: os.unlink(meta.file_path) - except OSError: - log.error("Failed to delete file %(file)s (Permission denied)", meta.file_path) - flash(_(u"Failed to delete file %(file)s (Permission denied).", file= meta.file_path), - category="warning") + except OSError as e: + log.error("Failed to move file %s: %s", saved_filename, e) + flash(_(u"Failed to Move File %(file)s: %(error)s", file=saved_filename, error=e), category="error") + return Response(json.dumps({"location": url_for("web.index")}), mimetype='application/json') if meta.cover is None: has_cover = 0 @@ -719,7 +714,15 @@ def upload(): os.path.join(filepath, "cover.jpg")) else: has_cover = 1 - move(meta.cover, os.path.join(filepath, "cover.jpg")) + try: + copyfile(meta.cover, os.path.join(filepath, "cover.jpg")) + os.unlink(meta.cover) + except OSError as e: + log.error("Failed to move cover file %s: %s", os.path.join(filepath, "cover.jpg"), e) + flash(_(u"Failed to Move Cover File %(file)s: %(error)s", file=os.path.join(filepath, "cover.jpg"), + error=e), + category="error") + return Response(json.dumps({"location": url_for("web.index")}), mimetype='application/json') # handle authors is_author = db.session.query(db.Authors).filter(db.Authors.name == authr).first() diff --git a/test/Calibre-Web TestSummary.html b/test/Calibre-Web TestSummary.html old mode 100644 new mode 100755 index ea31b506..4f560221 --- a/test/Calibre-Web TestSummary.html +++ b/test/Calibre-Web TestSummary.html @@ -36,17 +36,17 @@
-

Start Time: 2020-05-01 13:35:57

+

Start Time: 2020-05-05 19:02:03

-

Stop Time: 2020-05-01 14:32:26

+

Stop Time: 2020-05-05 19:58:37

-

Duration: 47:49 min

+

Duration: 47:42 min

@@ -1829,8 +1829,8 @@ AssertionError: False is not true : logfile config value is not empty after rese test_updater.test_updater 7 - 6 - 0 + 5 + 1 0 1 @@ -1867,11 +1867,33 @@ AssertionError: False is not true : logfile config value is not empty after rese - +
test_check_update_stable_versions
- PASS + +
+ FAIL +
+ + + + @@ -1924,8 +1946,8 @@ AssertionError: False is not true : logfile config value is not empty after rese test_user_template.test_user_template 19 - 18 - 1 + 19 + 0 0 0 @@ -2088,31 +2110,11 @@ AssertionError: False is not true : logfile config value is not empty after rese - +
test_series_user_template
- -
- FAIL -
- - - - + PASS @@ -2574,7 +2576,7 @@ AssertionError: False is not true SQLAlchemy-Utils - 0.36.4 + 0.36.5 test_OAuth_login