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
399dffba
Commit
399dffba
authored
Nov 03, 2018
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
log file name in case of filename not found (#691)
parent
8d6d28eb
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
14 deletions
+11
-14
helper.py
cps/helper.py
+5
-1
web.py
cps/web.py
+6
-13
No files found.
cps/helper.py
View file @
399dffba
...
@@ -377,7 +377,11 @@ def do_download_file(book, book_format, data, headers):
...
@@ -377,7 +377,11 @@ def do_download_file(book, book_format, data, headers):
else
:
else
:
abort
(
404
)
abort
(
404
)
else
:
else
:
response
=
make_response
(
send_from_directory
(
os
.
path
.
join
(
ub
.
config
.
config_calibre_dir
,
book
.
path
),
data
.
name
+
"."
+
book_format
))
filename
=
os
.
path
.
join
(
ub
.
config
.
config_calibre_dir
,
book
.
path
)
if
not
os
.
path
.
isfile
(
os
.
path
.
join
(
filename
,
data
.
name
+
"."
+
book_format
)):
# ToDo: improve error handling
web
.
app
.
logger
.
error
(
'File not found:
%
s'
%
os
.
path
.
join
(
filename
,
data
.
name
+
"."
+
book_format
))
response
=
make_response
(
send_from_directory
(
filename
,
data
.
name
+
"."
+
book_format
))
response
.
headers
=
headers
response
.
headers
=
headers
return
response
return
response
...
...
cps/web.py
View file @
399dffba
...
@@ -2255,7 +2255,8 @@ def read_book(book_id, book_format):
...
@@ -2255,7 +2255,8 @@ def read_book(book_id, book_format):
extensionList = ["cbt","cbz"]
extensionList = ["cbt","cbz"]
for fileext in extensionList:
for fileext in extensionList:
if book_format.lower() == fileext:
if book_format.lower() == fileext:
return render_title_template('readcbr.html', comicfile=book_id, extension=fileext, title=_(u"Read a Book"), book=book)
return render_title_template('readcbr.html', comicfile=book_id,
extension=fileext, title=_(u"Read a Book"), book=book)
flash(_(u"Error opening eBook. File does not exist or file is not accessible."), category="error")
flash(_(u"Error opening eBook. File does not exist or file is not accessible."), category="error")
return redirect(url_for("index"))'''
return redirect(url_for("index"))'''
...
@@ -2266,7 +2267,8 @@ def read_book(book_id, book_format):
...
@@ -2266,7 +2267,8 @@ def read_book(book_id, book_format):
def
get_download_link
(
book_id
,
book_format
):
def
get_download_link
(
book_id
,
book_format
):
book_format
=
book_format
.
split
(
"."
)[
0
]
book_format
=
book_format
.
split
(
"."
)[
0
]
book
=
db
.
session
.
query
(
db
.
Books
)
.
filter
(
db
.
Books
.
id
==
book_id
)
.
first
()
book
=
db
.
session
.
query
(
db
.
Books
)
.
filter
(
db
.
Books
.
id
==
book_id
)
.
first
()
data
=
db
.
session
.
query
(
db
.
Data
)
.
filter
(
db
.
Data
.
book
==
book
.
id
)
.
filter
(
db
.
Data
.
format
==
book_format
.
upper
())
.
first
()
data
=
db
.
session
.
query
(
db
.
Data
)
.
filter
(
db
.
Data
.
book
==
book
.
id
)
\
.
filter
(
db
.
Data
.
format
==
book_format
.
upper
())
.
first
()
if
data
:
if
data
:
# collect downloaded books only for registered user and not for anonymous user
# collect downloaded books only for registered user and not for anonymous user
if
current_user
.
is_authenticated
:
if
current_user
.
is_authenticated
:
...
@@ -2280,18 +2282,9 @@ def get_download_link(book_id, book_format):
...
@@ -2280,18 +2282,9 @@ def get_download_link(book_id, book_format):
headers
[
"Content-Type"
]
=
mimetypes
.
types_map
[
'.'
+
book_format
]
headers
[
"Content-Type"
]
=
mimetypes
.
types_map
[
'.'
+
book_format
]
except
KeyError
:
except
KeyError
:
headers
[
"Content-Type"
]
=
"application/octet-stream"
headers
[
"Content-Type"
]
=
"application/octet-stream"
headers
[
"Content-Disposition"
]
=
"attachment; filename*=UTF-8''
%
s.
%
s"
%
(
quote
(
file_name
.
encode
(
'utf-8'
)),
book_format
)
headers
[
"Content-Disposition"
]
=
"attachment; filename*=UTF-8''
%
s.
%
s"
%
(
quote
(
file_name
.
encode
(
'utf-8'
)),
book_format
)
return
helper
.
do_download_file
(
book
,
book_format
,
data
,
headers
)
return
helper
.
do_download_file
(
book
,
book_format
,
data
,
headers
)
#if config.config_use_google_drive:
# df = gdriveutils.getFileFromEbooksFolder(book.path, '%s.%s' % (data.name, book_format))
# if df:
# return do_gdrive_download(df, headers)
# else:
# abort(404)
#else:
# response = make_response(send_from_directory(os.path.join(config.config_calibre_dir, book.path), data.name + "." + book_format))
# response.headers = headers
# return response
else
:
else
:
abort
(
404
)
abort
(
404
)
...
...
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