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
d4aaea6f
Commit
d4aaea6f
authored
13 years ago
by
Matthieu Gonnet
Committed by
Seblu
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add clean command
Seblu: Fix too many things... Signed-off-by:
Seblu
<
sebastien.luttringer@smartjog.com
>
parent
401c15a5
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
bin/is
+4
-1
4 additions, 1 deletion
bin/is
installsystems/repository.py
+30
-0
30 additions, 0 deletions
installsystems/repository.py
with
34 additions
and
1 deletion
bin/is
+
4
−
1
View file @
d4aaea6f
...
...
@@ -103,7 +103,9 @@ def c_clean(parser, args):
'''
Clean a repository
'''
raise
NotImplementedError
(
"
Not yet implemented
"
)
repoman
=
load_repositories
(
args
)
for
reponame
in
args
.
repository
:
repoman
[
reponame
].
clean
()
def
c_copy
(
parser
,
args
):
'''
...
...
@@ -320,6 +322,7 @@ p_cat.set_defaults(func=c_cat)
# clean command parser
p_clean
=
subparsers
.
add_parser
(
"
clean
"
,
help
=
c_clean
.
__doc__
.
lower
())
p_clean
.
add_argument
(
"
repository
"
,
nargs
=
"
+
"
,
help
=
"
repositories to clean
"
)
p_clean
.
set_defaults
(
func
=
c_clean
)
# copy command parser
...
...
This diff is collapsed.
Click to expand it.
installsystems/repository.py
+
30
−
0
View file @
d4aaea6f
...
...
@@ -175,6 +175,36 @@ class Repository(object):
arrow
(
os
.
path
.
basename
(
obj
.
path
),
1
)
os
.
unlink
(
obj
.
path
)
def
getallmd5
(
self
):
'''
Get list of all md5 in DB
'''
res
=
self
.
db
.
ask
(
"
SELECT md5 FROM image UNION SELECT md5 FROM payload
"
).
fetchall
()
return
[
md5
[
0
]
for
md5
in
res
]
def
clean
(
self
):
'''
Clean the repository
'
s content
'''
# Check if the repo is local
if
not
istools
.
isfile
(
self
.
config
.
path
):
raise
Exception
(
"
Repository must be local
"
)
allmd5
=
set
(
self
.
getallmd5
())
repofiles
=
set
(
os
.
listdir
(
self
.
config
.
path
))
-
set
([
self
.
config
.
dbname
,
self
.
config
.
lastname
])
dirtyfiles
=
repofiles
-
allmd5
if
len
(
dirtyfiles
)
>
0
:
if
not
confirm
(
"
Remove dirty files? (yes)
"
):
raise
Exception
(
"
Aborted!
"
)
for
f
in
dirtyfiles
:
p
=
os
.
path
.
join
(
self
.
config
.
path
,
f
)
try
:
if
os
.
path
.
isdir
(
p
):
os
.
rmdir
(
p
)
else
:
os
.
unlink
(
p
)
except
:
raise
Exception
(
"
Removing %s failed
"
%
p
)
def
delete
(
self
,
name
,
version
):
'''
Delete an image from repository
...
...
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