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
8c509e4f
Commit
8c509e4f
authored
13 years ago
by
Matthieu Gonnet
Committed by
Seblu
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add check command
Signed-off-by:
Seblu
<
sebastien.luttringer@smartjog.com
>
parent
a4ca3823
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
+13
-0
13 additions, 0 deletions
bin/is
installsystems/repository.py
+21
-0
21 additions, 0 deletions
installsystems/repository.py
with
34 additions
and
0 deletions
bin/is
+
13
−
0
View file @
8c509e4f
...
...
@@ -99,6 +99,14 @@ def c_cat(parser, args):
for
filename
in
args
.
file
:
img
.
cat
(
filename
)
def
c_check
(
parser
,
args
):
'''
Check for unreferenced and missing files inside a repository
'''
repoman
=
load_repositories
(
args
)
for
reponame
in
args
.
repository
:
repoman
[
reponame
].
check
()
def
c_clean
(
parser
,
args
):
'''
Clean a repository
...
...
@@ -320,6 +328,11 @@ p_cat.add_argument("file", nargs="+",
help
=
"
file inside image to cat (globbing allowed)
"
)
p_cat
.
set_defaults
(
func
=
c_cat
)
# check command parser
p_check
=
subparsers
.
add_parser
(
"
check
"
,
help
=
c_check
.
__doc__
.
lower
())
p_check
.
add_argument
(
"
repository
"
,
nargs
=
"
+
"
,
help
=
"
repositories to check
"
)
p_check
.
set_defaults
(
func
=
c_check
)
# clean command parser
p_clean
=
subparsers
.
add_parser
(
"
clean
"
,
help
=
c_clean
.
__doc__
.
lower
())
p_clean
.
add_argument
(
"
repository
"
,
nargs
=
"
+
"
,
help
=
"
repositories to clean
"
)
...
...
This diff is collapsed.
Click to expand it.
installsystems/repository.py
+
21
−
0
View file @
8c509e4f
...
...
@@ -182,6 +182,27 @@ class Repository(object):
res
=
self
.
db
.
ask
(
"
SELECT md5 FROM image UNION SELECT md5 FROM payload
"
).
fetchall
()
return
[
md5
[
0
]
for
md5
in
res
]
def
check
(
self
):
'''
Check repository for unreferenced and missing files
'''
# Check if the repo is local
if
not
istools
.
isfile
(
self
.
config
.
path
):
raise
Exception
(
"
Repository must be local
"
)
local_files
=
set
(
os
.
listdir
(
self
.
config
.
path
))
db_files
=
set
(
self
.
getallmd5
())
db_files
.
add
(
self
.
config
.
dbname
)
db_files
.
add
(
self
.
config
.
lastname
)
# compute missing and unref files list
missing_files
=
db_files
-
local_files
unref_files
=
local_files
-
db_files
if
len
(
missing_files
)
>
0
:
arrow
(
"
Missing files:
"
)
out
(
os
.
linesep
.
join
(
missing_files
))
if
len
(
unref_files
)
>
0
:
arrow
(
"
Unreferenced files:
"
)
out
(
os
.
linesep
.
join
(
unref_files
))
def
clean
(
self
):
'''
Clean the repository
'
s content
...
...
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