Fix return value when access failure 37/229137/3 accepted/tizen/unified/20200331.031020 submit/tizen/20200330.065305
authorMinje Ahn <minje.ahn@samsung.com>
Mon, 30 Mar 2020 04:30:00 +0000 (13:30 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Mon, 30 Mar 2020 05:54:15 +0000 (14:54 +0900)
Change-Id: I1971d917c92d2bda2d50c14837cdbe03b5f88206
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
src/media-thumbnail.c

index 2b986de..46b1f21 100755 (executable)
@@ -370,21 +370,25 @@ static int __check_path_validity(const char *path)
 static int __check_thumb_path_validity(const char *path)
 {
        char *dir_name = NULL;
+       int ret = MS_MEDIA_ERR_NONE;
 
        thumb_retvm_if(!path, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid path");
 
        dir_name = g_path_get_dirname(path);
-       if (dir_name) {
-               if (access(dir_name, W_OK) != 0) {
+
+       if (access(dir_name, W_OK) != 0) {
+               if (errno == EACCES || errno == EPERM) {
                        thumb_err("No permission to write[%s]", dir_name);
-                       SAFE_FREE(dir_name);
-                       return MS_MEDIA_ERR_PERMISSION_DENIED;
+                       ret = MS_MEDIA_ERR_PERMISSION_DENIED;
+               } else {
+                       thumb_err("Does not exists[%s]", dir_name);
+                       ret = MS_MEDIA_ERR_INVALID_PARAMETER;
                }
-
-               SAFE_FREE(dir_name);
        }
 
-       return MS_MEDIA_ERR_NONE;
+       SAFE_FREE(dir_name);
+
+       return ret;
 }
 
 static int __check_parameter_validity_for_file(const char *path, unsigned int width, unsigned int height, const char *thumb_path)