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
a7bfdfd6
authored
Apr 01, 2014
by
Guba Sándor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
download: refactored abort check
parent
4427422b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
6 deletions
+9
-6
disk.py
+9
-6
No files found.
disk.py
View file @
a7bfdfd6
...
@@ -121,6 +121,8 @@ class Disk(object):
...
@@ -121,6 +121,8 @@ class Disk(object):
if
r
.
status_code
==
200
:
if
r
.
status_code
==
200
:
class
AbortException
(
Exception
):
class
AbortException
(
Exception
):
pass
pass
if
task
.
is_aborted
():
raise
AbortException
()
if
parent_id
is
None
:
if
parent_id
is
None
:
parent_id
=
task
.
request
.
id
parent_id
=
task
.
request
.
id
chunk_size
=
256
*
1024
chunk_size
=
256
*
1024
...
@@ -135,8 +137,6 @@ class Disk(object):
...
@@ -135,8 +137,6 @@ class Disk(object):
try
:
try
:
with
open
(
disk_path
,
'wb'
)
as
f
:
with
open
(
disk_path
,
'wb'
)
as
f
:
for
chunk
in
r
.
iter_content
(
chunk_size
=
chunk_size
):
for
chunk
in
r
.
iter_content
(
chunk_size
=
chunk_size
):
if
task
.
is_aborted
():
raise
AbortException
()
if
ext
in
(
'gz'
,
'bz'
):
if
ext
in
(
'gz'
,
'bz'
):
chunk
=
decompressor
.
decompress
(
chunk
)
chunk
=
decompressor
.
decompress
(
chunk
)
f
.
write
(
chunk
)
f
.
write
(
chunk
)
...
@@ -144,10 +144,13 @@ class Disk(object):
...
@@ -144,10 +144,13 @@ class Disk(object):
new_percent
=
min
(
100
,
round
(
actsize
*
100.0
/
clen
))
new_percent
=
min
(
100
,
round
(
actsize
*
100.0
/
clen
))
if
new_percent
>
percent
:
if
new_percent
>
percent
:
percent
=
new_percent
percent
=
new_percent
task
.
update_state
(
if
not
task
.
is_aborted
():
task_id
=
parent_id
,
task
.
update_state
(
state
=
task
.
AsyncResult
(
parent_id
)
.
state
,
task_id
=
parent_id
,
meta
=
{
'size'
:
actsize
,
'percent'
:
percent
})
state
=
task
.
AsyncResult
(
parent_id
)
.
state
,
meta
=
{
'size'
:
actsize
,
'percent'
:
percent
})
else
:
raise
AbortException
()
if
ext
==
'gz'
:
if
ext
==
'gz'
:
f
.
write
(
decompressor
.
flush
())
f
.
write
(
decompressor
.
flush
())
f
.
flush
()
f
.
flush
()
...
...
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