aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLianhao Lu <lianhao.lu@intel.com>2019-11-21 11:11:20 +0800
committerLianhao Lu <lianhao.lu@intel.com>2019-11-21 11:11:52 +0800
commit7897b7abd305cf079c6bc973f0fcb804d989a96f (patch)
treef9ef7d9827238a3c6133f5c890125b9a5e76aa6a
parent1ee29e00b88d8a4dde7a02575ad416f1615d1c7c (diff)
Add non-empty directory zip entries in the csar
Issue-ID: VNFSDK-517 Change-Id: Ib699949ae72a3d3a7d141ad5ddc331343dac16ac Signed-off-by: Lianhao Lu <lianhao.lu@intel.com>
-rw-r--r--vnfsdk_pkgtools/packager/csar.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/vnfsdk_pkgtools/packager/csar.py b/vnfsdk_pkgtools/packager/csar.py
index af84974..1bf5c20 100644
--- a/vnfsdk_pkgtools/packager/csar.py
+++ b/vnfsdk_pkgtools/packager/csar.py
@@ -142,6 +142,13 @@ def write(source, entry, destination, args):
LOG.debug('Compressing root directory to ZIP')
with zipfile.ZipFile(destination, 'w', zipfile.ZIP_DEFLATED) as f:
for root, dirs, files in os.walk(source):
+ # add dir entries
+ for dir in dirs:
+ dir_full_path = os.path.join(root, dir)
+ dir_relative_path = os.path.relpath(dir_full_path, source) + os.sep
+ LOG.debug('Writing to archive: {0}'.format(dir_relative_path))
+ f.write(dir_full_path + os.sep, dir_relative_path)
+
for file in files:
file_full_path = os.path.join(root, file)
# skip manifest file here in case we need to generate digest
@@ -152,13 +159,6 @@ def write(source, entry, destination, args):
if manifest_file and args.digest:
LOG.debug('Update file digest: {0}'.format(file_relative_path))
manifest_file.add_file(file_relative_path, args.digest)
- # add empty dir
- for dir in dirs:
- dir_full_path = os.path.join(root, dir)
- if len(os.listdir(dir_full_path)) == 0:
- dir_relative_path = os.path.relpath(dir_full_path, source) + os.sep
- LOG.debug('Writing to archive: {0}'.format(dir_relative_path))
- f.write(dir_full_path + os.sep, dir_relative_path)
if manifest_file:
LOG.debug('Update manifest file to temporary file')