fix param name for uploadFile
This commit is contained in:
parent
50bcb6f3bc
commit
65f5b6489b
2 changed files with 13 additions and 9 deletions
|
|
@ -10317,7 +10317,7 @@ class RootExports(object):
|
||||||
context.session.assertPerm('admin')
|
context.session.assertPerm('admin')
|
||||||
return make_task(*args, **opts)
|
return make_task(*args, **opts)
|
||||||
|
|
||||||
def uploadFile(self, path, name, size, md5sum, offset, data, volume=None):
|
def uploadFile(self, path, name, size, md5sum, offset, data, volume=None, checksum=None):
|
||||||
"""upload file to the hub
|
"""upload file to the hub
|
||||||
|
|
||||||
Files can be uploaded in chunks, if so the hash and size describe the
|
Files can be uploaded in chunks, if so the hash and size describe the
|
||||||
|
|
@ -10326,12 +10326,14 @@ class RootExports(object):
|
||||||
:param str path: the relative path to upload to
|
:param str path: the relative path to upload to
|
||||||
:param str name: the name of the file
|
:param str name: the name of the file
|
||||||
:param int size: size of contents (bytes)
|
:param int size: size of contents (bytes)
|
||||||
:param str md5sum: md5sum (hex digest) of contents or tuple (hash_type, digest)
|
:param checksum: MD5 hex digest (see md5sum) or a tuple (hash_type, digest) of contents
|
||||||
md5sum name is misleading, but it is here for backwas compatibility
|
:type checksum: str or tuple
|
||||||
:param str data: base64 encoded file contents
|
:param str data: base64 encoded file contents
|
||||||
:param int offset: The offset indicates where the chunk belongs.
|
:param int offset: The offset indicates where the chunk belongs.
|
||||||
The special offset -1 is used to indicate the final
|
The special offset -1 is used to indicate the final
|
||||||
chunk.
|
chunk.
|
||||||
|
:param str md5sum: legacy param name of checksum. md5sum name is misleading,
|
||||||
|
but it is here for backwards compatibility
|
||||||
|
|
||||||
:returns: True
|
:returns: True
|
||||||
"""
|
"""
|
||||||
|
|
@ -10341,14 +10343,16 @@ class RootExports(object):
|
||||||
# we will accept offset and size as strings to work around xmlrpc limits
|
# we will accept offset and size as strings to work around xmlrpc limits
|
||||||
offset = koji.decode_int(offset)
|
offset = koji.decode_int(offset)
|
||||||
size = koji.decode_int(size)
|
size = koji.decode_int(size)
|
||||||
if isinstance(md5sum, str):
|
if checksum is None and md5sum is not None:
|
||||||
|
checksum = md5sum
|
||||||
|
if isinstance(checksum, str):
|
||||||
# this case is for backwards compatibility
|
# this case is for backwards compatibility
|
||||||
verify = "md5"
|
verify = "md5"
|
||||||
digest = hash
|
digest = checksum
|
||||||
elif hash is None:
|
elif checksum is None:
|
||||||
verify = None
|
verify = None
|
||||||
else:
|
else:
|
||||||
verify, digest = hash
|
verify, digest = checksum
|
||||||
sum_cls = get_verify_class(verify)
|
sum_cls = get_verify_class(verify)
|
||||||
if offset != -1:
|
if offset != -1:
|
||||||
if size is not None:
|
if size is not None:
|
||||||
|
|
|
||||||
|
|
@ -775,14 +775,14 @@ class VMExecTask(BaseTaskHandler):
|
||||||
fobj.close()
|
fobj.close()
|
||||||
return len(data)
|
return len(data)
|
||||||
|
|
||||||
def uploadDirect(self, filepath, offset, size, hash, data):
|
def uploadDirect(self, filepath, offset, size, checksum, data):
|
||||||
"""
|
"""
|
||||||
Upload contents directly to the server.
|
Upload contents directly to the server.
|
||||||
"""
|
"""
|
||||||
remotepath = os.path.dirname(os.path.join(self.getUploadDir(), filepath))
|
remotepath = os.path.dirname(os.path.join(self.getUploadDir(), filepath))
|
||||||
filename = os.path.basename(filepath)
|
filename = os.path.basename(filepath)
|
||||||
self.session.uploadFile(remotepath, filename, size,
|
self.session.uploadFile(remotepath, filename, size,
|
||||||
hash, offset, data)
|
checksum, offset, data)
|
||||||
|
|
||||||
def verifyChecksum(self, path, checksum, algo='sha1'):
|
def verifyChecksum(self, path, checksum, algo='sha1'):
|
||||||
local_path = os.path.abspath(os.path.join(self.output_dir, path))
|
local_path = os.path.abspath(os.path.join(self.output_dir, path))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue