avose / GLShell

OpenGL Terminal
GNU Lesser General Public License v2.1
3 stars 0 forks source link

Cleanup DirectoryTree Scanning Code #43

Closed avose closed 1 year ago

avose commented 1 year ago

The code that handles updating the graph when the filesystem changes needs a round of code cleanup. There are two goals:

1) Make the code cleaner; it's a bit ad-hoc and messy. 2) Performance; the code it probably very slow due to poor design w.r.t. deletions. This should be fixed in at least one of the following ways: 2a) Have the graph update code work in three phases: 2a1) Collect a bunch of events from the watcher in some small time window. 2a2) After the time window has expired, process the events. First, rescan the filesystem for all the files and directories on disk. 2a3) After filesystem scanning is complete, lock the graph and update only the nodes and edges dictionaries, not the np* numpy arrays. Once the dictionaries are updated, make a pass and regenerate the numpy np* objects.

This will clean things up and make it faster, and hopefully less prone to errors.

avose commented 1 year ago

Yeah, the code doesn't work even as well as I thought as-is. Needs work. Hopefully a re-write with the above process will help.

I'm currently seeing that the tree can become disjointed during file remove operations, and things go flying apart in the graph..

avose commented 1 year ago

I rewrote things to do pretty much all of this. Things are not perfect in the sense that in pathological cases one can get some error popups, but there doesn't appear to be any graph corruption at least. Also, I just rebuild the entire tree when rescanning, which can be slow. However, it does work reasonably well, and again, the project size is limited by the physical calculation anyway..