summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhyunho <hhstark.kang@samsung.com>2020-09-04 15:54:17 +0900
committerhyunho <hhstark.kang@samsung.com>2020-09-07 11:30:12 +0900
commit6d33931f89333573d9ab8a6d60f1be5025a936c3 (patch)
tree2efb12773c02fc4ff93c73a532ff54522ba92edc
parentadf41c9c1e75c02b83a2e49522b2c3f901091cf2 (diff)
downloadnotification-6d33931f89333573d9ab8a6d60f1be5025a936c3.tar.gz
notification-6d33931f89333573d9ab8a6d60f1be5025a936c3.tar.bz2
notification-6d33931f89333573d9ab8a6d60f1be5025a936c3.zip
Use file name that contains path info
The temporary files which are generated by the DataProviderMaster, can be overrided if they have same file name but different hierarchy. For now, files have below hierarchy will be copied to the temporary folder with name a.jpg so that one file will override other file. Folder1 | |-a.jpg Folder2 | |-a.jpg To fix this problem, let's use following naming rule for the temporary files. _{folder name}_{file name} According to this naming rule, above example files' name will be _Folder1_a.jpg and _Folder2_a.jpg Change-Id: I8d19b1a7f9ee998da2e7da90a79bd645bf8b960c Signed-off-by: hyunho <hhstark.kang@samsung.com>
-rw-r--r--notification/src/notification_shared_file.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/notification/src/notification_shared_file.c b/notification/src/notification_shared_file.c
index c8bcfe6..b7ce797 100644
--- a/notification/src/notification_shared_file.c
+++ b/notification/src/notification_shared_file.c
@@ -75,6 +75,7 @@ typedef struct target_app_info {
char *dbus_sender_name;
} target_app_info_s;
+static const char *__last_index_of(const char *path, const char *search);
static bool __make_sharing_dir(const char *dir)
{
GFile *noti_dir = NULL;
@@ -103,10 +104,12 @@ static bool __make_sharing_dir(const char *dir)
}
static char *__get_data_path_by_pkg_id(const char *pkg_id,
- const char *file_name, uid_t uid)
+ const char *file_path, uid_t uid)
{
const char *path;
- char dir[PATH_MAX];
+ char dir[PATH_MAX * 2];
+ char rel_file_path[PATH_MAX];
+ const char *pkg_path;
if (pkg_id == NULL)
return NULL;
@@ -118,13 +121,27 @@ static char *__get_data_path_by_pkg_id(const char *pkg_id,
if (path == NULL)
return NULL;
- snprintf(dir, sizeof(dir), "%s/%s/%s", path, pkg_id, NOTI_PRIV_DATA_DIR);
+ pkg_path = __last_index_of(file_path, pkg_id);
+ if (pkg_path == NULL) {
+ ERR("Wrong file path : cannot find pkgid");
+ return NULL;
+ }
+
+ snprintf(rel_file_path, sizeof(rel_file_path), "%s",
+ pkg_path + strlen(pkg_id));
+
+ for (int i = 0; i < strlen(rel_file_path); i++) {
+ if (rel_file_path[i] == '/')
+ rel_file_path[i] = '_';
+ }
+ snprintf(dir, sizeof(dir), "%s/%s/%s",
+ path, pkg_id, NOTI_PRIV_DATA_DIR);
if (__make_sharing_dir(dir) == false)
return NULL;
snprintf(dir, sizeof(dir), "%s/%s/%s/%s", path, pkg_id,
- NOTI_PRIV_DATA_DIR, file_name);
+ NOTI_PRIV_DATA_DIR, rel_file_path);
return strdup(dir);
}
@@ -674,8 +691,7 @@ char *notification_check_file_path_is_private(const char *pkg_id,
}
if (__is_RO_file(smack_label))
- dst_path = __get_data_path_by_pkg_id(pkg_id,
- __last_index_of(file_path, "/") + 1, uid);
+ dst_path = __get_data_path_by_pkg_id(pkg_id, file_path, uid);
if (dst_path == NULL && __is_private_file(smack_label, pkg_id)) {
dst_path = strdup(file_path);