RIFT 16526 Copy the icon image also to the UI logos location for UI update.
[osm/SO.git] / rwlaunchpad / plugins / rwpkgmgr / rift / tasklets / rwpkgmgr / proxy / filesystem.py
index 6cfc0fa..7111092 100644 (file)
@@ -22,6 +22,7 @@ import os
 
 import rift.package.store as store
 import rift.package.package
+import rift.package.icon as icon
 
 from .base import AbstractPackageManagerProxy
 
@@ -83,9 +84,10 @@ class FileSystemProxy(AbstractPackageManagerProxy):
         # the first part will always be the vnfd/nsd name
         mode = 0o664
 
-        # for files other than README, create the package path from the asset type
+        # for files other than README, create the package path from the asset type, e.g. icons/icon1.png
+        # for README files, strip off any leading '/' 
         package_path = package_file_type + "/" + package_path \
-            if package_file_type != "readme" else package_path
+            if package_file_type != "readme" else package_path.strip('/')
         components = package_path.split("/")
         if len(components) > 2:
             schema = components[1]
@@ -100,12 +102,20 @@ class FileSystemProxy(AbstractPackageManagerProxy):
         path = store._get_package_dir(package_id)
         dest_file = os.path.join(path, package.prefix, package_path)
 
+        # Insert (by copy) the file in the package location. For icons, 
+        # insert also in UI location for UI to pickup
         try:
             package.insert_file(new_file, dest_file, package_path, mode=mode)
+
+            if package_file_type == 'icons': 
+                icon_extract = icon.PackageIconExtractor(self.log) 
+                icon_extract.extract_icons(package)
+
         except rift.package.package.PackageAppendError as e:
             self.log.exception(e)
             return False
 
+        self.log.debug("File insertion complete at {}".format(dest_file))
         return True
 
     def package_file_delete(self, package_type, package_id, package_path, package_file_type):