Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
douban-api-proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
douban-api-proxy
Commits
89c0904a
Commit
89c0904a
authored
Sep 14, 2018
by
bodybybuddha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix to #625 - Check to see if target book format already exists before executing conversion.
parent
968cddf2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
+19
-0
worker.py
cps/worker.py
+19
-0
No files found.
cps/worker.py
View file @
89c0904a
...
...
@@ -232,10 +232,29 @@ class WorkerThread(threading.Thread):
bookid
=
self
.
queue
[
self
.
current
][
'bookid'
]
format_old_ext
=
u'.'
+
self
.
queue
[
self
.
current
][
'settings'
][
'old_book_format'
]
.
lower
()
format_new_ext
=
u'.'
+
self
.
queue
[
self
.
current
][
'settings'
][
'new_book_format'
]
.
lower
()
# check to see if destination format already exists -
# if it does - mark the conversion task as complete and return a success
# this will allow send to kindle workflow to continue to work
if
os
.
path
.
isfile
(
file_path
+
format_new_ext
):
web
.
app
.
logger
.
info
(
"Book id
%
d already converted to
%
s"
,
bookid
,
format_new_ext
)
cur_book
=
web
.
db
.
session
.
query
(
web
.
db
.
Books
)
.
filter
(
web
.
db
.
Books
.
id
==
bookid
)
.
first
()
self
.
queue
[
self
.
current
][
'path'
]
=
file_path
self
.
queue
[
self
.
current
][
'title'
]
=
cur_book
.
title
self
.
queue
[
self
.
current
][
'status'
]
=
STAT_FINISH_SUCCESS
self
.
UIqueue
[
self
.
current
][
'status'
]
=
_
(
'Finished'
)
self
.
UIqueue
[
self
.
current
][
'progress'
]
=
"100
%
"
self
.
UIqueue
[
self
.
current
][
'runtime'
]
=
self
.
_formatRuntime
(
datetime
.
now
()
-
self
.
queue
[
self
.
current
][
'starttime'
])
return
file_path
+
format_new_ext
else
:
web
.
app
.
logger
.
info
(
"Book id
%
d - target format of
%
s does not existing. Moving forward with convert."
,
bookid
,
format_new_ext
)
# check if converter-executable is existing
if
not
os
.
path
.
exists
(
web
.
ub
.
config
.
config_converterpath
):
self
.
_handleError
(
_
(
u"Convertertool
%(converter)
s not found"
,
converter
=
web
.
ub
.
config
.
config_converterpath
))
return
try
:
# check which converter to use kindlegen is "1"
if
format_old_ext
==
'.epub'
and
format_new_ext
==
'.mobi'
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment