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
d38b8d58
Commit
d38b8d58
authored
13 years ago
by
Seblu
Browse files
Options
Downloads
Patches
Plain Diff
Fix repository deletion
Now use databases function to delete files from repository
parent
184b64a2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
installsystems/database.py
+11
-0
11 additions, 0 deletions
installsystems/database.py
installsystems/repository.py
+16
-22
16 additions, 22 deletions
installsystems/repository.py
with
27 additions
and
22 deletions
installsystems/database.py
+
11
−
0
View file @
d38b8d58
...
...
@@ -58,6 +58,7 @@ class Database(object):
'''
Deltete a packaged image
'''
arrow
(
"
Removing metadata from db
"
,
1
,
self
.
verbose
)
newdb_path
=
"
%s.new
"
%
self
.
path
fname
=
"
%s-%s.json
"
%
(
name
,
version
)
try
:
db
=
Tarball
.
open
(
self
.
path
,
mode
=
'
r:bz2
'
)
newdb
=
Tarball
.
open
(
newdb_path
,
mode
=
'
w:bz2
'
)
...
...
@@ -70,6 +71,16 @@ class Database(object):
except
Exception
as
e
:
raise
Exception
(
"
Removing metadata fail: %s
"
%
e
)
def
databalls
(
self
,
name
,
version
):
'''
List data tarballs filenames
'''
try
:
db
=
Tarball
.
open
(
self
.
path
,
mode
=
'
r:bz2
'
)
jdesc
=
json
.
loads
(
db
.
get_str
(
"
%s-%s.json
"
%
(
name
,
version
)))
db
.
close
()
return
jdesc
[
"
data
"
]
except
Exception
as
e
:
raise
Exception
(
"
Listing data tarballs fail: %s
"
%
e
)
def
find
(
self
,
name
,
version
=
None
):
'''
Find last version of an image
'''
try
:
...
...
This diff is collapsed.
Click to expand it.
installsystems/repository.py
+
16
−
22
View file @
d38b8d58
...
...
@@ -9,7 +9,6 @@ Repository stuff
import
os
import
time
import
shutil
import
json
import
installsystems
import
installsystems.tools
as
istools
from
installsystems.printer
import
*
...
...
@@ -82,33 +81,28 @@ class Repository(object):
def
delete
(
self
,
name
,
version
):
'''
Delete an image from repository
'''
name
=
"
%s-%s
"
%
(
name
,
version
)
fname
=
"
%s.json
"
%
name
# FIXME: check tarball exists before doing this
tbs
=
self
.
tarballs
(
name
)
if
self
.
db
.
find
(
name
,
version
)
is
None
:
error
(
"
Unable to find %s version %s in database
"
%
(
name
,
version
))
# removing script tarballs
arrow
(
"
Removing script tarball
"
,
1
,
self
.
verbose
)
tpath
=
os
.
path
.
join
(
self
.
image_path
,
"
%s-%s%s
"
%
(
name
,
version
,
Image
.
image_extension
))
if
os
.
path
.
exists
(
tpath
):
os
.
unlink
(
tpath
)
arrow
(
"
%s removed
"
%
os
.
path
.
basename
(
tpath
),
2
,
self
.
verbose
)
# removing data tarballs
arrow
(
"
Removing data tarballs
"
,
1
,
self
.
verbose
)
for
tb
in
self
.
db
.
databalls
(
name
,
version
):
tpath
=
os
.
path
.
join
(
self
.
data_path
,
tb
)
if
os
.
path
.
exists
(
tpath
):
os
.
unlink
(
tpath
)
arrow
(
"
%s removed
"
%
tb
,
2
,
self
.
verbose
)
# removing metadata
self
.
db
.
delete
(
name
,
version
)
# removing tarballs
arrow
(
"
Removing tarballs
"
,
1
,
self
.
verbose
)
for
tb
in
tbs
:
arrow
(
"
Removing %s
"
%
os
.
path
.
basename
(
tb
),
2
,
self
.
verbose
)
os
.
unlink
(
tb
)
# update last file
arrow
(
"
Updating last file
"
,
1
,
self
.
verbose
)
self
.
update_last
()
def
tarballs
(
self
,
name
):
'''
List all tarballs (script + data)
'''
ts
=
list
()
# add script tarballs
ts
.
append
(
os
.
path
.
abspath
(
os
.
path
.
join
(
self
.
image_path
,
"
%s%s
"
%
(
name
,
Image
.
image_extension
))))
tempdb
=
Tarball
.
open
(
self
.
db_path
,
mode
=
'
r:bz2
'
)
jdesc
=
json
.
loads
(
tempdb
.
get_str
(
"
%s.json
"
%
name
))
for
dt
in
jdesc
[
"
data
"
]:
ts
.
append
(
os
.
path
.
abspath
(
os
.
path
.
join
(
self
.
data_path
,
dt
)))
return
ts
class
RepositoryCache
(
object
):
'''
Local repository cache class
'''
...
...
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