Big time Ruby novice here; I apologize in advance.
I’m looking to create a Ruby app that generates a folder/sub-folder
index file every time the main folder is updated (i.e., new sub-folders
are added, renamed, etc.). Everything seems pretty simple and straight
forward. The only part I’m having a hard time “pre-engineering” is the
folder update/trigger file update part. That is, how can I get my
app–while running in the background–to update my index file every time
there is a folder update? Can anyone point me to a class/method that
might help?
Alternative would be to lazily update the index whenever it is
accessed. Depends which approach is more promising. Rule of thumb:
if there are rare updates but frequent index accesses push approach
(inotify) will be better. If there are frequent updates but only rare
index accesses pull (my alternative) will be better. YMMV though.
Alternative would be to lazily update the index whenever it is
accessed. Depends which approach is more promising. Rule of thumb:
if there are rare updates but frequent index accesses push approach
(inotify) will be better. If there are frequent updates but only rare
index accesses pull (my alternative) will be better. YMMV though.
Kind regards
robert
Robert,
Thanks for the advice. I never even thought about that. Unfortunately,
the index-accesses to folder-updates ratio will be about 10:1. Not to
mention, the index will be pulled in “bursts” so it would slow things
down a bit if it had to be updated every time it was read. Not a bad
idea though.
The win32-changenotify library lets you monitor files or directories
for certain events, such as when a file is created, modified, deleted,
etc.
Although deprecated in favor of win32-changejournal on NTFS
filesystems, this library is still maintained because not everyone
uses NTFS. It also has the advantage of being pure Ruby, which may or
may not be a selling point for you.
Thanks, Steel. A big caveat I forgot to mention is that the folder(s)
are located on a Windows based system. From my limited research, it
looks like I’ll want to dig into the win32ole class–maybe…
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.