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
8d2a8654
Commit
8d2a8654
authored
Apr 17, 2016
by
JanB
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Catch file permission errors when uploading PDF
parent
df480160
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
2 deletions
+10
-2
web.py
cps/web.py
+10
-2
No files found.
cps/web.py
View file @
8d2a8654
...
...
@@ -861,8 +861,16 @@ def upload():
filepath
=
config
.
DB_ROOT
+
"/"
+
author_dir
+
"/"
+
title_dir
saved_filename
=
filepath
+
"/"
+
data_name
+
fileextension
if
not
os
.
path
.
exists
(
filepath
):
try
:
os
.
makedirs
(
filepath
)
except
OSError
:
flash
(
"Failed to create path
%
s (Permission denied)."
%
filepath
,
category
=
"error"
)
return
redirect
(
url_for
(
'index'
))
try
:
file
.
save
(
saved_filename
)
except
OSError
:
flash
(
"Failed to store file
%
s (Permission denied)."
%
saved_filename
,
category
=
"error"
)
return
redirect
(
url_for
(
'index'
))
file_size
=
os
.
path
.
getsize
(
saved_filename
)
has_cover
=
0
if
fileextension
.
upper
()
==
".PDF"
:
...
...
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