From c22dac0df1e0f3d89d09b31f39afc0ca211f6c29 Mon Sep 17 00:00:00 2001 From: Lingxian Kong Date: Mon, 27 Nov 2017 12:04:21 +1300 Subject: [PATCH] Fix function package update Change-Id: I534978de7ccc65f00ca09e32eddc1b829af47925 --- qinling/storage/file_system.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/qinling/storage/file_system.py b/qinling/storage/file_system.py index e8784fee..f85dd9b6 100644 --- a/qinling/storage/file_system.py +++ b/qinling/storage/file_system.py @@ -46,14 +46,17 @@ class FileSystemStorage(base.PackageStorage): 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(func_zip, 'wb') as fd: + with open(new_func_zip, 'wb') as fd: fd.write(data) - if not zipfile.is_zipfile(func_zip): - fileutils.delete_if_exists(func_zip) + 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) + def retrieve(self, project_id, function): """Get function package data.