Page 1 of 1

update an rtree dynamically

Posted: Tue Oct 11, 2011 12:49 pm
by strayeye
Hi.

Firstly I am new to this so am sorry if im asking a question with a simple answer.

I have built my rtree within my project from a file system. Is there a way to dynamically update my tree ? i.e if I add another file into one of the folders can I get rtree to display the file without having to rebuild the tree ? I would assume you can write some code to do this on preopenstack ???

Any help would be appreciated

Thanks
Jimmy

Re: update an rtree dynamically

Posted: Wed Oct 12, 2011 11:10 am
by wilstrand
Hi Jimmy!

No need to excuse yourself! Your question is highly valid!

Besides rebuilding the tree, there is no easy way to dynamically update (synchronize) rTree with changes in a file system. Problem is that you have to keep track of if a file or folder has been added or deleted and compare that with the rTree node data. This requires some way to have a unique identifier for every file/folder in your file system with the same identifier as a property of the corresponding node in your tree. One way forward here could be to use the creation time stamp of the files/folders in your file system as unique identifiers. From the time stamps you could then also check if a file/folder is newer than the latest node in your rTree. Depending on what synchronizing functionality you want, this becomes rather complicated though.

In most cases it is much easier and more reliable to rebuild the whole tree when changes to the file system has been made or as you suggests, when opening the app in an preOpenStack handler.

With my best regards

Mats

Re: update an rtree dynamically

Posted: Tue Oct 18, 2011 9:04 am
by strayeye
Hi Mats.

Many thanks for your reply. I ended up rebuilding the whole tree. Just put the code on the preOpen Stack script so when I open the app it checks what is there and then renders the tree. I also added a refresh button to my app to re-render the tree on the push of a button.

Thanks again

Jimmy