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
5d42a07f
authored
Oct 28, 2020
by
Máhonfai Bálint
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't convert imported image if it is already qcow2
parent
349cb3f5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
8 deletions
+17
-8
disk.py
+17
-8
No files found.
disk.py
View file @
5d42a07f
import
shutil
import
json
import
os
import
subprocess
...
...
@@ -270,16 +272,23 @@ class Disk(object):
r
=
requests
.
get
(
url
,
stream
=
True
)
downloaded_file
=
os
.
path
.
join
(
self
.
dir
,
url
.
split
(
'/'
)[
-
1
])
with
open
(
downloaded_file
,
'wb'
)
as
f
:
f
.
write
(
r
.
content
)
for
chunk
in
r
.
iter_content
(
chunk_size
=
8192
):
f
.
write
(
chunk
)
cmdline
=
[
'qemu-img'
,
'convert'
,
'-O'
,
'qcow2'
,
downloaded_file
,
self
.
get_path
()]
subprocess
.
check_output
(
cmdline
)
with
magic
.
Magic
()
as
m
:
ftype
=
m
.
id_filename
(
downloaded_file
)
if
'qcow'
in
ftype
.
lower
():
shutil
.
move
(
downloaded_file
,
self
.
get_path
())
else
:
cmdline
=
[
'qemu-img'
,
'convert'
,
'-O'
,
'qcow2'
,
downloaded_file
,
self
.
get_path
()]
subprocess
.
check_output
(
cmdline
)
os
.
unlink
(
downloaded_file
)
os
.
unlink
(
downloaded_file
)
if
not
self
.
check_valid_image
():
os
.
unlink
(
self
.
get_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