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
3f907f82
Commit
3f907f82
authored
13 years ago
by
Seblu
Browse files
Options
Downloads
Patches
Plain Diff
Remove original file after adding to db
This can be avoided by -p
parent
16e70d7b
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
+3
-1
3 additions, 1 deletion
bin/is
installsystems/repository.py
+10
-5
10 additions, 5 deletions
installsystems/repository.py
with
13 additions
and
6 deletions
bin/is
+
3
−
1
View file @
3f907f82
...
...
@@ -88,7 +88,7 @@ def c_add(parser, args):
raise
Exception
(
"
Please select one repository
"
)
repo
=
Repository
(
repos
[
0
])
pkg
=
PackageImage
(
args
.
path
)
repo
.
add
(
pkg
)
repo
.
add
(
pkg
,
delete
=
not
args
.
preserve
)
except
Exception
as
e
:
raise
Exception
(
"
add failed: %s
"
%
e
)
...
...
@@ -210,6 +210,8 @@ p_build.set_defaults(func=c_build)
# add command parser
p_add
=
subparsers
.
add_parser
(
"
add
"
,
help
=
c_add
.
__doc__
.
lower
())
p_add
.
add_argument
(
'
-p
'
,
"
--preserve
"
,
action
=
"
store_true
"
,
default
=
False
,
help
=
"
don
'
t remove image after adding to database
"
)
p_add
.
add_argument
(
"
path
"
)
p_add
.
set_defaults
(
func
=
c_add
)
...
...
This diff is collapsed.
Click to expand it.
installsystems/repository.py
+
10
−
5
View file @
3f907f82
...
...
@@ -85,9 +85,10 @@ class Repository(object):
raise
Exception
(
"
Read last file failed: %s
"
%
e
)
return
0
def
add
(
self
,
image
):
def
add
(
self
,
image
,
delete
=
False
):
'''
Add a packaged image to repository
if delete is true, remove original files
'''
# check local repository
if
istools
.
pathtype
(
self
.
config
.
path
)
!=
"
file
"
:
...
...
@@ -99,17 +100,15 @@ class Repository(object):
image
.
check
(
"
Check image and payload before copy
"
)
# adding file to repository
arrow
(
"
Copying images and payload
"
)
arrowlevel
(
1
)
for
obj
in
[
image
]
+
image
.
payload
.
values
():
dest
=
os
.
path
.
join
(
self
.
config
.
path
,
obj
.
md5
)
basesrc
=
os
.
path
.
basename
(
obj
.
path
)
if
os
.
path
.
exists
(
dest
):
arrow
(
"
Skipping %s: already exists
"
%
basesrc
)
arrow
(
"
Skipping %s: already exists
"
%
basesrc
,
1
)
else
:
arrow
(
"
Adding %s (%s)
"
%
(
basesrc
,
obj
.
md5
))
arrow
(
"
Adding %s (%s)
"
%
(
basesrc
,
obj
.
md5
)
,
1
)
istools
.
copy
(
obj
.
path
,
dest
,
self
.
config
.
uid
,
self
.
config
.
gid
,
self
.
config
.
fmod
)
arrowlevel
(
-
1
)
# copy is done. create a image inside repo
r_image
=
PackageImage
(
os
.
path
.
join
(
self
.
config
.
path
,
image
.
md5
),
md5name
=
True
)
...
...
@@ -145,6 +144,12 @@ class Repository(object):
self
.
db
.
commit
()
# update last file
self
.
update_last
()
# removing orginal files
if
delete
:
arrow
(
"
Removing original files
"
)
for
obj
in
[
image
]
+
image
.
payload
.
values
():
arrow
(
os
.
path
.
basename
(
obj
.
path
),
1
)
os
.
unlink
(
obj
.
path
)
def
delete
(
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