[pmwiki-users] pagelists link= with pages generated externally

Patrick R. Michaud pmichaud at pobox.com
Thu May 24 08:13:20 CDT 2007


On Thu, May 24, 2007 at 10:13:24AM +0200, Christophe David wrote:
> >    http://www.pmwiki.org/wiki/Cookbook/ImportText
> 
> "Whenever this script detects that the import/ directory has changed,
> or at intervals given by $ImportFreq (in seconds), it scans the
> import/ directory to see if there are any new files to be imported."
> 
> Could you please explain how this works ?
> 
> How/when does the script detect that the import/ directory has changed? 
> Is it every time the recipe is launched, or every time the recipe is
> launched AND the last check was performed more than $ImportFreq ago ?

The recipe detects that the import/ directory has changed by
simply comparing the last modification time of the directory with 
the last modification time of the .lastimport file.  If the
import/ directory has a later timestamp, then we know that 
_something_ has happened and so we need to check it for new
import files.

When the recipe is loaded, this quick comparison of the 
directory timestamp occurs at the end of every browse request 
($action == 'browse').  It's just comparing the timestamps of
two files, so the additional load on the server is minimal.

Since it's possible that files in the import directory change
without affecting the last modification time of the directory
itself, the site administrator can set $ImportFreq to force
checking of the import/ directory after a certain interval
even if the directory's last modification time hasn't changed.

> If I want to have the files imported as soon as possible, is there a
> drawback in setting $ImportFreq=1 knowing that pages are only imported
> once ?

Setting $ImportFreq to 1 or some other low value will mean
that the import/ directory will be scanned for new files 
(and the .lastimport file updated) on virtually _every_
browse request.  It's entirely up to the site admin to
decide if that's reasonable for the server.

One item that isn't in the script yet (that I need to add)
is to avoid importing "partial" text files -- i.e., when
ImportText is run while another program is in the process
of writing out the text file.  I'll probably do this by
making sure that each file hasn't been modified for at least
five seconds before importing it.

Pm



More information about the pmwiki-users mailing list