rimmed pushed a commit to branch master.

http://git.enlightenment.org/tools/eflete.git/commit/?id=f98caebb88696851dd0281b0e5d2a13f7d245bcf

commit f98caebb88696851dd0281b0e5d2a13f7d245bcf
Author: Mykyta Biliavskyi <[email protected]>
Date:   Wed Sep 28 17:18:24 2016 +0300

    Fix behaviour of _lock_try function.
    
    Correct processing errors and don't check lock status for non exists
    files.
    
    @svace WGID 23244, 23247
---
 src/bin/project_manager/project_manager2.c | 16 +++++++++++++++-
 src/bin/ui/tab_home_import_edc.c           |  3 ++-
 src/bin/ui/tab_home_import_edj.c           |  4 +++-
 3 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/src/bin/project_manager/project_manager2.c 
b/src/bin/project_manager/project_manager2.c
index e97a4c5..be22aa4 100644
--- a/src/bin/project_manager/project_manager2.c
+++ b/src/bin/project_manager/project_manager2.c
@@ -20,6 +20,7 @@
 #define _GNU_SOURCE
 #include "project_manager2.h"
 #include <fcntl.h>
+#include <errno.h>
 
 #ifndef _WIN32
 #include <sys/wait.h>
@@ -414,13 +415,24 @@ _lock_try(const char *path, Eina_Bool check, int *pro_fd)
    struct flock lock, savelock;
 
    int fd = open(path, O_RDWR);
+   if (fd < 1)
+     {
+        ERR(" %s\n", strerror(errno));
+        return check;
+     }
+
    lock.l_type    = F_WRLCK;   /* Test for any lock on any part of file. */
    lock.l_whence  = SEEK_SET;
    lock.l_start   = 0;
    lock.l_len     = 0;
    lock.l_pid     = 0;
    savelock = lock;
-   fcntl(fd, F_GETLK, &lock);  /* Overwrites lock structure with preventors. */
+   if (fcntl(fd, F_GETLK, &lock) == -1)
+     {
+        ERR("Failed get lock status of file [%s] error message [%s].\n", path, 
strerror(errno));
+        close(fd);
+        return false;
+     }
    if ((lock.l_pid != 0) && ((lock.l_type == F_WRLCK) || (lock.l_type == 
F_RDLCK)))
      {
         ERR("Process %d has a write lock already!", lock.l_pid);
@@ -1431,5 +1443,7 @@ pm_project_release_export(Project *project,
 Eina_Bool
 pm_lock_check(const char *path)
 {
+   if (ecore_file_exists(path) == false)
+     return true;
    return _lock_try(path, false, NULL);
 }
diff --git a/src/bin/ui/tab_home_import_edc.c b/src/bin/ui/tab_home_import_edc.c
index 8a1e2b6..2c69db6 100644
--- a/src/bin/ui/tab_home_import_edc.c
+++ b/src/bin/ui/tab_home_import_edc.c
@@ -437,8 +437,9 @@ _import(void *data __UNUSED__,
        return;
 
    buf = eina_strbuf_new();
-   eina_strbuf_append_printf(buf, "%s/%s.pro",
+   eina_strbuf_append_printf(buf, "%s/%s/%s.pro",
                              elm_entry_entry_get(tab_edc.path),
+                             elm_entry_entry_get(tab_edc.name),
                              elm_entry_entry_get(tab_edc.name));
    if (!pm_lock_check(eina_strbuf_string_get(buf)))
      {
diff --git a/src/bin/ui/tab_home_import_edj.c b/src/bin/ui/tab_home_import_edj.c
index 68b29ff..354dcc8 100644
--- a/src/bin/ui/tab_home_import_edj.c
+++ b/src/bin/ui/tab_home_import_edj.c
@@ -487,9 +487,11 @@ _import(void *data __UNUSED__,
        return;
 
    buf = eina_strbuf_new();
-   eina_strbuf_append_printf(buf, "%s/%s.pro",
+   eina_strbuf_append_printf(buf, "%s/%s/%s.pro",
                              elm_entry_entry_get(tab_edj.path),
+                             elm_entry_entry_get(tab_edj.name),
                              elm_entry_entry_get(tab_edj.name));
+
    if (!pm_lock_check(eina_strbuf_string_get(buf)))
      {
        popup_add(_("Import EDJ-file"), _("The given file is locked by another 
application"), BTN_OK, NULL, NULL);

-- 


Reply via email to