Ephoto: Properly identify symlinks and handle them accordingly.

This commit is contained in:
Stephen okra Houston 2016-08-09 17:10:47 -05:00
parent d996dd64e3
commit 421483d5d7
3 changed files with 38 additions and 20 deletions

View File

@ -311,11 +311,13 @@ struct _Ephoto_Entry
double size;
Ephoto *ephoto;
Eio_Monitor *monitor;
Eio_Monitor *link_monitor;
Eina_List *monitor_handlers;
Elm_Object_Item *item;
Elm_Object_Item *parent;
Eina_List *free_listeners;
Eina_Bool is_dir;
Eina_Bool is_link;
Eina_Bool no_delete;
Evas_Object *genlist;
};

View File

@ -754,28 +754,37 @@ _delete_thread_cb(void *data, Ecore_Thread *et EINA_UNUSED)
{
char dest[PATH_MAX], fp[PATH_MAX], extra[PATH_MAX];
int ret;
struct stat s;
snprintf(fp, PATH_MAX, "%s", file);
snprintf(dest, PATH_MAX, "%s/%s", destination, basename(fp));
if (ecore_file_exists(dest))
{
snprintf(extra, PATH_MAX, "%s/CopyOf%s", destination,
basename(fp));
if (ecore_file_exists(extra))
{
int count;
for (count = 2; ecore_file_exists(extra); count++)
{
memset(extra, 0, sizeof(extra));
snprintf(extra, PATH_MAX, "%s/Copy%dOf%s",
destination, count, basename(fp));
}
}
ret = ecore_file_mv(file, extra);
}
lstat(file, &s);
if (S_ISLNK(s.st_mode))
{
ret = ecore_file_unlink(file);
}
else
ret = ecore_file_mv(file, dest);
{
snprintf(fp, PATH_MAX, "%s", file);
snprintf(dest, PATH_MAX, "%s/%s", destination, basename(fp));
if (ecore_file_exists(dest))
{
snprintf(extra, PATH_MAX, "%s/CopyOf%s", destination,
basename(fp));
if (ecore_file_exists(extra))
{
int count;
for (count = 2; ecore_file_exists(extra); count++)
{
memset(extra, 0, sizeof(extra));
snprintf(extra, PATH_MAX, "%s/Copy%dOf%s",
destination, count, basename(fp));
}
}
ret = ecore_file_mv(file, extra);
}
else
ret = ecore_file_mv(file, dest);
}
if (!ret)
ephoto->file_errors++;
}

View File

@ -1088,6 +1088,11 @@ ephoto_entry_new(Ephoto *ephoto, const char *path, const char *label,
entry->is_dir = EINA_TRUE;
else
entry->is_dir = EINA_FALSE;
if (type == EINA_FILE_LNK)
entry->is_link = EINA_TRUE;
else
entry->is_link = EINA_FALSE;
return entry;
}
@ -1132,6 +1137,8 @@ ephoto_entry_free(Ephoto *ephoto, Ephoto_Entry *entry)
eina_stringshare_del(entry->label);
if (entry->monitor)
{
if (entry->link_monitor)
eio_monitor_del(entry->link_monitor);
eio_monitor_del(entry->monitor);
EINA_LIST_FREE(entry->monitor_handlers, handler)
ecore_event_handler_del(handler);