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
Commit
8e09feed
authored
Mar 01, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor percent counting in Disk.download
parent
6462577a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
10 deletions
+6
-10
disk.py
+6
-10
No files found.
disk.py
View file @
8e09feed
...
@@ -120,9 +120,6 @@ class Disk(object):
...
@@ -120,9 +120,6 @@ class Disk(object):
pass
pass
if
parent_id
is
None
:
if
parent_id
is
None
:
parent_id
=
task
.
request
.
id
parent_id
=
task
.
request
.
id
percent_size
=
float
(
r
.
headers
[
'content-length'
])
/
100
percent
=
0
actual_size
=
0
chunk_size
=
256
*
1024
chunk_size
=
256
*
1024
ext
=
url
.
split
(
'.'
)[
-
1
]
.
lower
()
ext
=
url
.
split
(
'.'
)[
-
1
]
.
lower
()
if
ext
==
'gz'
:
if
ext
==
'gz'
:
...
@@ -139,16 +136,15 @@ class Disk(object):
...
@@ -139,16 +136,15 @@ class Disk(object):
raise
AbortException
()
raise
AbortException
()
if
ext
in
(
'gz'
,
'bz'
):
if
ext
in
(
'gz'
,
'bz'
):
chunk
=
decompressor
.
decompress
(
chunk
)
chunk
=
decompressor
.
decompress
(
chunk
)
if
chunk
:
f
.
write
(
chunk
)
f
.
write
(
chunk
)
actual_size
+=
chunk_size
actsize
=
f
.
tell
()
if
actual_size
>
(
percent_size
*
percent
):
new_percent
=
min
(
100
,
round
(
actsize
*
100.0
/
clen
))
percent
+=
1
if
new_percent
>
percent
:
percent
=
new_percent
task
.
update_state
(
task
.
update_state
(
task_id
=
parent_id
,
task_id
=
parent_id
,
state
=
task
.
AsyncResult
(
parent_id
)
.
state
,
state
=
task
.
AsyncResult
(
parent_id
)
.
state
,
meta
=
{
'size'
:
actual_size
,
meta
=
{
'size'
:
actsize
,
'percent'
:
percent
})
'percent'
:
percent
})
if
ext
==
'gz'
:
if
ext
==
'gz'
:
f
.
write
(
decompressor
.
flush
())
f
.
write
(
decompressor
.
flush
())
f
.
flush
()
f
.
flush
()
...
@@ -170,7 +166,7 @@ class Disk(object):
...
@@ -170,7 +166,7 @@ class Disk(object):
task
.
update_state
(
task
.
update_state
(
task_id
=
parent_id
,
task_id
=
parent_id
,
state
=
task
.
AsyncResult
(
parent_id
)
.
state
,
state
=
task
.
AsyncResult
(
parent_id
)
.
state
,
meta
=
{
'size'
:
act
ual_
size
,
'extracting'
:
'zip'
,
meta
=
{
'size'
:
actsize
,
'extracting'
:
'zip'
,
'percent'
:
99
})
'percent'
:
99
})
self
.
extract_iso_from_zip
(
disk_path
)
self
.
extract_iso_from_zip
(
disk_path
)
...
...
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