improve app2sd stability 87/79187/2 accepted/tizen/common/20160708.184213 accepted/tizen/ivi/20160709.015245 accepted/tizen/mobile/20160709.020625 accepted/tizen/tv/20160709.015228 accepted/tizen/wearable/20160709.020535 submit/tizen/20160708.145338
authorjongmyeongko <jongmyeong.ko@samsung.com>
Fri, 8 Jul 2016 14:09:00 +0000 (23:09 +0900)
committerjongmyeongko <jongmyeong.ko@samsung.com>
Fri, 8 Jul 2016 14:47:31 +0000 (23:47 +0900)
- do not handle as failure in case source dir does not exists.
(some application has no 'lib')
- sync() after pre/post called.
- bugfix kill all running apps when sdcard is removed.

Change-Id: Ied0578a840f4216ff461150532fea22854b4753d
Signed-off-by: jongmyeongko <jongmyeong.ko@samsung.com>
plugin/app2sd/src/app2sd_interface.c
plugin/app2sd/src/app2sd_internals.c
plugin/app2sd/src/app2sd_internals_registry.c
plugin/app2sd/src/app2sd_internals_utils.c

index 2991b8b..1e3c217 100644 (file)
@@ -848,6 +848,7 @@ int app2sd_usr_pre_move_installed_app(const char *pkgid,
                }
        }
 
+       sync();
        return APP2EXT_SUCCESS;
 }
 
index 9b336cc..b0d8c93 100644 (file)
@@ -1089,7 +1089,6 @@ int _app2sd_move_app_to_external(const char *pkgid, GList *dir_list, uid_t uid)
                goto ERR;
        }
 
-       sync();
        return APP2EXT_SUCCESS;
 
 ERR:
@@ -1291,14 +1290,14 @@ int _app2sd_move_app_to_internal(const char *pkgid, GList *dir_list, uid_t uid)
                        ret = unlink(temp_dir_path);
                        if (ret) {
                                if (errno == ENOENT) {
-                                       _E("directory (%s) does not exist",
+                                       _W("directory (%s) does not exist",
                                                temp_dir_path);
                                } else {
                                        _E("unable to remove the symbolic link file (%s)," \
                                                " it is already unlinked",
                                                temp_dir_path);
+                                       goto ERR;
                                }
-                               goto ERR;
                        }
 
                        /* Copy content to destination */
index c235889..b94dd9f 100644 (file)
@@ -265,7 +265,7 @@ int _app2sd_get_foreach_info_from_db(app2sd_info_cb cb_func)
                ret = cb_func(pkgid, (uid_t)uid);
                if (ret) {
                        _E("app2sd info callback error");
-                       break;
+                       /* continue */
                }
        }
 
index dbc6025..f0cd8f2 100644 (file)
@@ -161,7 +161,7 @@ void _app2sd_delete_symlink(const char *dirname)
                                _E("force unlink [%s]", abs_filename);
                                if (unlink(abs_filename)) {
                                        if (errno == ENOENT)
-                                               _E("Unable to access file %s", abs_filename);
+                                               _W("Unable to access file %s", abs_filename);
                                        else
                                                _E("Unable to delete %s", abs_filename);
                                }
@@ -185,10 +185,39 @@ void _app2sd_delete_symlink(const char *dirname)
 int _app2sd_copy_dir(const char *src, const char *dest)
 {
        int ret = APP2EXT_SUCCESS;
+       DIR *dir = NULL;
        const char *argv_bin[] = { "/bin/cp", "-raf", src, dest, NULL };
+
+       /* check existence  before copy */
+       dir = opendir(src);
+       if (dir) {
+               closedir(dir);
+       } else {
+               if (errno == ENOENT) {
+                       _W("src(%s) not exist, skip!", src);
+                       return ret;
+               } else {
+                       _E("failed to open src(%s) dir, errno(%d)", errno);
+                       return APP2EXT_ERROR_MOVE;
+               }
+       }
+
+       dir = opendir(dest);
+       if (dir) {
+               closedir(dir);
+       } else {
+               if (errno == ENOENT) {
+                       _E("dest(%s) not exist, failed!", dest);
+                       return APP2EXT_ERROR_MOVE;
+               } else {
+                       _E("failed to open dest(%s) dir, errno(%d)", errno);
+                       return APP2EXT_ERROR_MOVE;
+               }
+       }
+
        ret = _xsystem(argv_bin);
        if (ret) {
-               _E("copy fail");
+               _E("failed to copy dir, errno(%d)", errno);
                return APP2EXT_ERROR_MOVE;
        }
        return ret;