bugfix related storing external_path
[platform/core/appfw/app2sd.git] / plugin / app2sd / src / app2sd_interface.c
index 8bc6b29..40e2cf8 100644 (file)
@@ -874,6 +874,10 @@ int app2sd_usr_pre_move_installed_app(const char *pkgid,
 
        /* if move is completed, then update installed storage to pkgmgr_parser db */
        if (move_type == APP2EXT_MOVE_TO_EXT) {
+               if (!image_path) {
+                       _E("image_path is NULL");
+                       return APP2EXT_ERROR_MEMORY_ALLOC_FAILED;
+               }
                pkgmgr_ret = pkgmgrinfo_pkginfo_set_usr_installed_storage(pkgid,
                                INSTALL_EXTERNAL, image_path, uid);
                if (pkgmgr_ret < 0) {
@@ -893,6 +897,9 @@ int app2sd_usr_pre_move_installed_app(const char *pkgid,
                }
        }
 
+       if (image_path)
+               free(image_path);
+
        sync();
        return APP2EXT_SUCCESS;
 }
@@ -1189,6 +1196,7 @@ int app2sd_usr_post_app_upgrade(const char *pkgid,
        char *device_name = NULL;
        char *encoded_id = NULL;
        int ret = APP2EXT_SUCCESS;
+       int pkgmgr_ret = 0;
 
        /* validate the function parameter recieved */
        if (pkgid == NULL || install_status < APP2EXT_STATUS_FAILED
@@ -1274,6 +1282,15 @@ int app2sd_usr_post_app_upgrade(const char *pkgid,
        }
 #endif
 
+       pkgmgr_ret = pkgmgrinfo_pkginfo_set_usr_installed_storage(pkgid,
+               INSTALL_EXTERNAL, loopback_device, uid);
+       if (pkgmgr_ret < 0) {
+               _E("fail to update installed location " \
+                       "to db[%s, %d] of uid(%d), pkgmgr ret(%d)",
+                       pkgid, INSTALL_EXTERNAL, uid, pkgmgr_ret);
+               return APP2EXT_ERROR_PKGMGR_ERROR;
+       }
+
        if (device_name) {
                free(device_name);
                device_name = NULL;