def store(self, project_id, function, data):
"""Store the function package data to local file system.
:param project_id: Project ID.
:param function: Function ID.
:param data: Package data.
"""
LOG.info(
'Store package, function: %s, project: %s', function, project_id
)
project_path = os.path.join(CONF.storage.file_system_dir, project_id)
fileutils.ensure_tree(project_path)
new_func_zip = os.path.join(project_path, '%s.zip.new' % function)
func_zip = os.path.join(project_path, '%s.zip' % function)
with open(new_func_zip, 'wb') as fd:
fd.write(data)
if not zipfile.is_zipfile(new_func_zip):
fileutils.delete_if_exists(new_func_zip)
raise exc.InputException("Package is not a valid ZIP package.")
os.rename(new_func_zip, func_zip)
评论列表
文章目录