Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
installsystems
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Seblu
installsystems
Commits
8d02ec9c
Commit
8d02ec9c
authored
13 years ago
by
Seblu
Browse files
Options
Downloads
Patches
Plain Diff
improve tarball loading and check md5 from repository
parent
f88c786c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
installsystems/image.py
+7
-1
7 additions, 1 deletion
installsystems/image.py
installsystems/repository.py
+9
-5
9 additions, 5 deletions
installsystems/repository.py
with
16 additions
and
6 deletions
installsystems/image.py
+
7
−
1
View file @
8d02ec9c
...
...
@@ -17,6 +17,7 @@ import re
import
shutil
import
gzip
import
gzipstream
#until python support gzip not seekable
import
cStringIO
import
installsystems.template
as
istemplate
import
installsystems.tools
as
istools
from
installsystems.printer
import
*
...
...
@@ -359,7 +360,12 @@ class PackageImage(Image):
try
:
if
fileobj
is
None
:
fileobj
=
istools
.
uopen
(
self
.
path
)
self
.
_tarball
=
Tarball
.
open
(
fileobj
=
fileobj
,
mode
=
'
r:gz
'
)
memfile
=
cStringIO
.
StringIO
()
fileobj
.
seek
(
0
)
(
self
.
size
,
self
.
md5
)
=
istools
.
copyfileobj
(
fileobj
,
memfile
)
fileobj
.
close
()
memfile
.
seek
(
0
)
self
.
_tarball
=
Tarball
.
open
(
fileobj
=
memfile
,
mode
=
'
r:gz
'
)
except
Exception
as
e
:
raise
Exception
(
"
Unable to open image %s: %s
"
%
(
path
,
e
))
self
.
_metadata
=
self
.
read_metadata
()
...
...
This diff is collapsed.
Click to expand it.
installsystems/repository.py
+
9
−
5
View file @
8d02ec9c
...
...
@@ -277,19 +277,23 @@ class Repository(object):
r
=
self
.
db
.
ask
(
"
select md5 from image where name = ? and version = ? limit 1
"
,
(
name
,
version
)).
fetchone
()
if
r
is
None
:
raise
Exception
(
"
Unable to find image %s v
ersion
%s
"
%
(
name
,
version
))
raise
Exception
(
"
Unable to find image %s v%s
"
%
(
name
,
version
))
path
=
os
.
path
.
join
(
self
.
config
.
path
,
r
[
0
])
# getting the file
arrow
(
"
Loading image %s v%s from repository %s
"
%
(
name
,
version
,
self
.
config
.
name
))
memfile
=
cStringIO
.
StringIO
()
fo
=
istools
.
uopen
(
path
)
(
self
.
size
,
self
.
md5
)
=
istools
.
copyfileobj
(
fo
,
memfile
)
fo
.
close
()
try
:
fo
=
istools
.
uopen
(
path
)
istools
.
copyfileobj
(
fo
,
memfile
)
fo
.
close
()
except
Exception
as
e
:
raise
Exception
(
"
Loading image %s v%s failed: %s
"
%
(
name
,
version
,
e
))
memfile
.
seek
(
0
)
pkg
=
PackageImage
(
path
,
fileobj
=
memfile
,
md5name
=
True
)
pkg
.
md5
=
r
[
0
]
if
pkg
.
md5
!=
r
[
0
]:
raise
Exception
(
"
Image MD5 verification failure
"
)
return
pkg
def
getmd5
(
self
,
name
,
version
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment