summaryrefslogtreecommitdiff
path: root/src/lib/eio
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-04-02 08:50:34 -0400
committerMike Blumenkrantz <zmike@samsung.com>2019-04-02 08:50:34 -0400
commitc29dae34a0b8fc13a188a5a57a645368325240d4 (patch)
tree51f6a40e5a44d7cc8863078cf1a0f563c607deef /src/lib/eio
parentf5d3030d7bb42b067a4ffff28ff15351358107b9 (diff)
efl_io_model: start early on monitoring
Summary: Little introduction into what eio did before this commit: Efl.Io.Model creation: - direct ls of a directory in a thread (A) - take all the contents of a directory and feed it slowly back into the mainloop - when all events have been feeded back to the mainloop and have been processed: start monitoring (B) However, any file created between (A) and (B) will not be in the model, since not the listing nor the monitoring did caputure it. Hence we need to start monitoring before we actaully start listing. In the callbacks we then check if we already published something. ref T7311 Reviewers: zmike, cedric Reviewed By: cedric Subscribers: cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T7311 Differential Revision: https://phab.enlightenment.org/D8525
Diffstat (limited to 'src/lib/eio')
-rw-r--r--src/lib/eio/efl_io_model.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/src/lib/eio/efl_io_model.c b/src/lib/eio/efl_io_model.c
index f023ea7597..300dac0e21 100644
--- a/src/lib/eio/efl_io_model.c
+++ b/src/lib/eio/efl_io_model.c
@@ -57,6 +57,21 @@ _eio_file_error_cb(void *data, Eio_File *handler, int error)
57 pd->request.move = NULL; 57 pd->request.move = NULL;
58} 58}
59 59
60
61static Eina_Bool
62_already_added(Efl_Io_Model_Data *pd, const char *path)
63{
64 Efl_Io_Model_Info *mi;
65 Eina_List *node;
66
67 EINA_LIST_FOREACH(pd->files, node, mi)
68 {
69 if (!strcmp(mi->path, path))
70 return EINA_TRUE;
71 }
72 return EINA_FALSE;
73}
74
60/** 75/**
61 * Callbacks 76 * Callbacks
62 * Ecore Events 77 * Ecore Events
@@ -78,6 +93,9 @@ _efl_model_evt_added_ecore_cb(void *data, int type, void *event)
78 93
79 if (ev->monitor != pd->monitor) return EINA_TRUE; 94 if (ev->monitor != pd->monitor) return EINA_TRUE;
80 95
96 if (_already_added(pd, ev->filename))
97 return EINA_TRUE;
98
81 obj = pd->self; 99 obj = pd->self;
82 100
83 path = ecore_file_dir_get(ev->filename); 101 path = ecore_file_dir_get(ev->filename);
@@ -704,6 +722,8 @@ _efl_io_model_children_list(void *data, Eina_Array *entries)
704 { 722 {
705 Efl_Io_Model_Info *mi; 723 Efl_Io_Model_Info *mi;
706 724
725 if (_already_added(pd, info->path)) continue;
726
707 if (pd->filter.cb) 727 if (pd->filter.cb)
708 { 728 {
709 if (!pd->filter.cb(pd->filter.data, obj, info)) 729 if (!pd->filter.cb(pd->filter.data, obj, info))
@@ -733,18 +753,6 @@ _efl_io_model_children_list(void *data, Eina_Array *entries)
733 efl_event_callback_call(obj, EFL_MODEL_EVENT_CHILDREN_COUNT_CHANGED, NULL); 753 efl_event_callback_call(obj, EFL_MODEL_EVENT_CHILDREN_COUNT_CHANGED, NULL);
734} 754}
735 755
736static Eina_Value
737_efl_io_model_children_list_on(Eo *o EINA_UNUSED, void *data, const Eina_Value v)
738{
739 Efl_Io_Model_Data *pd = data;
740
741 // Now that we have listed the content of the directory,
742 // we can whatch over it
743 _efl_io_model_efl_model_monitor_add(pd);
744
745 return v;
746}
747
748static void 756static void
749_efl_io_model_children_list_cleanup(Eo *o EINA_UNUSED, void *data, const Eina_Future *dead_future EINA_UNUSED) 757_efl_io_model_children_list_cleanup(Eo *o EINA_UNUSED, void *data, const Eina_Future *dead_future EINA_UNUSED)
750{ 758{
@@ -787,8 +795,10 @@ _efl_io_model_efl_model_children_count_get(const Eo *obj, Efl_Io_Model_Data *pd)
787 f = efl_io_manager_direct_ls(iom, pd->path, EINA_FALSE, 795 f = efl_io_manager_direct_ls(iom, pd->path, EINA_FALSE,
788 (void*) obj, _efl_io_model_children_list, NULL); 796 (void*) obj, _efl_io_model_children_list, NULL);
789 797
798 //start monitoring before listing is done
799 //we will filter later on if we already published a file or not
800 _efl_io_model_efl_model_monitor_add(pd);
790 pd->request.listing = efl_future_then(obj, f, 801 pd->request.listing = efl_future_then(obj, f,
791 .success = _efl_io_model_children_list_on,
792 .free = _efl_io_model_children_list_cleanup, 802 .free = _efl_io_model_children_list_cleanup,
793 .data = pd); 803 .data = pd);
794 } 804 }