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
bf41b04c
Commit
bf41b04c
authored
Aug 23, 2020
by
blitzmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove convert task from db.py - with the fixed from #1565, this no longer seems to be needed
parent
9ce2e8ea
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
15 deletions
+11
-15
db.py
cps/db.py
+0
-12
convert.py
cps/tasks/convert.py
+11
-3
No files found.
cps/db.py
View file @
bf41b04c
...
@@ -352,20 +352,8 @@ class CalibreDB(threading.Thread):
...
@@ -352,20 +352,8 @@ class CalibreDB(threading.Thread):
if
i
==
'dummy'
:
if
i
==
'dummy'
:
self
.
queue
.
task_done
()
self
.
queue
.
task_done
()
break
break
if
i
[
'task'
]
==
'add_format'
:
cur_book
=
self
.
session
.
query
(
Books
)
.
filter
(
Books
.
id
==
i
[
'id'
])
.
first
()
cur_book
.
data
.
append
(
i
[
'format'
])
try
:
# db.session.merge(cur_book)
self
.
session
.
commit
()
except
OperationalError
as
e
:
self
.
session
.
rollback
()
self
.
log
.
error
(
"Database error:
%
s"
,
e
)
# self._handleError(_(u"Database error: %(error)s.", error=e))
# return
self
.
queue
.
task_done
()
self
.
queue
.
task_done
()
def
stop
(
self
):
def
stop
(
self
):
self
.
queue
.
put
(
'dummy'
)
self
.
queue
.
put
(
'dummy'
)
...
...
cps/tasks/convert.py
View file @
bf41b04c
...
@@ -6,6 +6,8 @@ import re
...
@@ -6,6 +6,8 @@ import re
from
glob
import
glob
from
glob
import
glob
from
shutil
import
copyfile
from
shutil
import
copyfile
from
sqlalchemy.exc
import
SQLAlchemyError
from
cps.services.worker
import
CalibreTask
from
cps.services.worker
import
CalibreTask
from
cps
import
calibre_db
,
db
from
cps
import
calibre_db
,
db
from
cps
import
logger
,
config
from
cps
import
logger
,
config
...
@@ -84,9 +86,15 @@ class TaskConvert(CalibreTask):
...
@@ -84,9 +86,15 @@ class TaskConvert(CalibreTask):
book
=
book_id
,
uncompressed_size
=
os
.
path
.
getsize
(
file_path
+
format_new_ext
))
book
=
book_id
,
uncompressed_size
=
os
.
path
.
getsize
(
file_path
+
format_new_ext
))
# todo: this may not be needed anymore, might be able to access the DB directly now. See #1565
# todo: this may not be needed anymore, might be able to access the DB directly now. See #1565
task
=
{
'task'
:
'add_format'
,
'id'
:
book_id
,
'format'
:
new_format
}
cur_book
=
calibre_db
.
session
.
query
(
db
.
Books
)
.
filter
(
db
.
Books
.
id
==
book_id
)
.
first
()
self
.
worker_thread
.
db_queue
.
put
(
task
)
cur_book
.
data
.
append
(
new_format
)
# To Do how to handle error?
try
:
# db.session.merge(cur_book)
calibre_db
.
session
.
commit
()
except
SQLAlchemyError
as
e
:
calibre_db
.
session
.
rollback
()
log
.
error
(
"Database error:
%
s"
,
e
)
'''cur_book.data.append(new_format)
'''cur_book.data.append(new_format)
try:
try:
...
...
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