Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
storagedriver
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
2
Merge Requests
4
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
Commit
205e1a73
authored
Nov 14, 2014
by
Guba Sándor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix file-size handling
parent
04b3aede
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
3 deletions
+12
-3
disk.py
+12
-3
No files found.
disk.py
View file @
205e1a73
...
...
@@ -26,6 +26,10 @@ class AbortException(Exception):
pass
class
FileTooBig
(
Exception
):
pass
class
Disk
(
object
):
''' Storage driver DISK object.
...
...
@@ -206,7 +210,9 @@ class Disk(object):
# undocumented zlib feature http://stackoverflow.com/a/2424549
elif
ext
==
'bz2'
:
decompressor
=
BZ2Decompressor
()
clen
=
min
(
int
(
r
.
headers
.
get
(
'content-length'
,
maximum_size
)),
1
)
clen
=
int
(
r
.
headers
.
get
(
'content-length'
,
maximum_size
))
if
clen
>
maximum_size
:
raise
FileTooBig
()
percent
=
0
try
:
with
open
(
disk_path
,
'wb'
)
as
f
:
...
...
@@ -216,8 +222,7 @@ class Disk(object):
f
.
write
(
chunk
)
actsize
=
f
.
tell
()
if
actsize
>
maximum_size
:
raise
Exception
(
"
%
s file is too big. Maximum size "
"is
%
s"
%
url
,
maximum_size
)
raise
FileTooBig
()
new_percent
=
min
(
100
,
round
(
actsize
*
100.0
/
clen
))
if
new_percent
>
percent
:
percent
=
new_percent
...
...
@@ -239,6 +244,10 @@ class Disk(object):
os
.
unlink
(
disk_path
)
logger
.
info
(
"Download
%
s aborted
%
s removed."
,
url
,
disk_path
)
except
FileTooBig
:
os
.
unlink
(
disk_path
)
raise
Exception
(
"
%
s file is too big. Maximum size "
"is
%
s"
%
url
,
maximum_size
)
except
:
os
.
unlink
(
disk_path
)
logger
.
error
(
"Download
%
s failed,
%
s removed."
,
...
...
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