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

Patrick R. Michaud pmichaud at pobox.com
Thu May 24 10:30:25 CDT 2007


On Thu, May 24, 2007 at 08:13:20AM -0500, Patrick R. Michaud wrote:
> On Thu, May 24, 2007 at 10:13:24AM +0200, Christophe David wrote:
> > 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.

Following up to my previous post, I should go ahead and
outline the other ways to get things imported quickly
without setting $ImportFreq to a low value.  First,
recall that...

> 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.

So, the key to getting things imported "as soon as possible"
is to make sure the last modification time of the import/ 
directory changes somehow when there's something new to be
imported.  Here are a few possibilities:

1.  When an external program is about to write a new text file
    in the import/ directory, make sure it first removes any 
    existing file of the same name.  This will cause the 
    timestamp of the import/ directory to update when the
    new file is created.

2.  Give PmWiki write permission to the import/ directory.
    If PmWiki has write permission to the import/ directory,
    then it will rename any files it imports to include a
    time marker in the name.  As a result, any new files
    placed in the import/ directory will automatically cause
    the directory's timestamp to change.  The InputText 
    script will see this on the very next browse request and
    start processing the files in the import/ directory.

3.  When an external program modifies a file in the import/
    directory, also have it briefly "touch" the import/
    directory itself.  On Unix-like systems there's a touch(1) 
    command that does this:

             touch import

    In PHP there's a touch() function that does a similar thing.

4.  One can also update the directory's last modified time by
    quickly creating and removing a temporary file in that
    directory.  

Hope some of these are useful.

Pm



More information about the pmwiki-users mailing list