1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-12-27 02:16:12 +01:00

copypac: make the server-side copy the default. But do a client-side copy if source and target are not on the same buildservice instance.

This commit is contained in:
Dr. Peter Poeml 2008-04-02 14:36:23 +00:00
parent f966f87c32
commit e62dd94cc0
2 changed files with 14 additions and 11 deletions

View File

@ -568,15 +568,20 @@ class Osc(cmdln.Cmdln):
return 1 return 1
aggregate_pac(src_project, src_package, dst_project, dst_package) aggregate_pac(src_project, src_package, dst_project, dst_package)
@cmdln.option('-s', '--server-side', action='store_true', @cmdln.option('-c', '--client-side-copy', action='store_true',
help='do a (faster) server-side copy') help='do a (slower) client-side copy')
@cmdln.option('-t', '--to-apiurl', metavar='URL', @cmdln.option('-t', '--to-apiurl', metavar='URL',
help='URL of destination api server. Default is the source api server.') help='URL of destination api server. Default is the source api server.')
def do_copypac(self, subcmd, opts, *args): def do_copypac(self, subcmd, opts, *args):
"""${cmd_name}: Copy a package """${cmd_name}: Copy a package
A client-side copy implementation. It can be done cross-project, or even A way to copy package to somewhere else.
across buildservice instances, if the -t option is used.
It can be done across buildservice instances, if the -t option is used.
In that case, a client-side copy is implied.
Using --client-side-copy always involves downloading all files, and
uploading them to the target.
The DESTPAC name is optional; the source packages' name will be used if The DESTPAC name is optional; the source packages' name will be used if
DESTPAC is omitted. DESTPAC is omitted.
@ -613,14 +618,12 @@ class Osc(cmdln.Cmdln):
print >>sys.stderr, 'Error: source and destination are the same.' print >>sys.stderr, 'Error: source and destination are the same.'
return 1 return 1
if opts.server_side and src_apiurl != dst_apiurl: if src_apiurl != dst_apiurl:
print >>sys.stderr, 'Error: a server-side copy can\'t be done to ' \ opts.client_side_copy = True
'copy from one API host to another.'
return 1
r = copy_pac(src_apiurl, src_project, src_package, r = copy_pac(src_apiurl, src_project, src_package,
dst_apiurl, dst_project, dst_package, dst_apiurl, dst_project, dst_package,
server_side=opts.server_side) client_side_copy=opts.client_side_copy)
print r print r

View File

@ -2357,7 +2357,7 @@ def aggregate_pac(src_project, src_package, dst_project, dst_package):
def copy_pac(src_apiurl, src_project, src_package, def copy_pac(src_apiurl, src_project, src_package,
dst_apiurl, dst_project, dst_package, dst_apiurl, dst_project, dst_package,
server_side = False): client_side_copy = False):
""" """
Create a copy of a package. Create a copy of a package.
@ -2375,7 +2375,7 @@ def copy_pac(src_apiurl, src_project, src_package,
http_PUT(u, data=src_meta) http_PUT(u, data=src_meta)
print 'Copying files...' print 'Copying files...'
if server_side: if not client_side_copy:
query = {'cmd': 'copy', 'oproject': src_project, 'opackage': src_package } query = {'cmd': 'copy', 'oproject': src_project, 'opackage': src_package }
u = makeurl(dst_apiurl, ['source', dst_project, dst_package], query=query) u = makeurl(dst_apiurl, ['source', dst_project, dst_package], query=query)
f = http_POST(u) f = http_POST(u)