Paul Seamons wrote:
On Thursday 10 May 2007 10:49 am, Travis Basevi wrote:
could the <=
instead be changed to == thus ensuring the compiled version has to match
(or at least have the same mtime) as the tt2 file?
I'd have to agree that I'd like to see this change. I think though that it
may have to do with systems that don't support utime. Perhaps we could do a
check at BEGIN time to see if utime is supported.
Seems like a good idea to me as well. Another simple idea might be to check the
modtime stored in the compiled template with the modtime of the file.
Disclaimer: the below was worked on quickly and may be prone to wrongness.
Sorry if this is wrong guys, I only looked really quick (I'm busy) and threw the
code in. I believe $data is Template::Document object, so we should be able to
grab the modtime with $data->modtime(). Of course this comes with the penalty
of having to eval the compiled file, but it's another way to make sure things are
correct.
if ($compiled && -f $compiled
&& (stat($path))[9] <= (stat($compiled))[9]) {
if ($data = $self->_load_compiled($compiled)) {
+ if($data->modtime() == stat($path))[9]){
# store in cache
$data = $self->store($path, $data);
$error = Template::Constants::STATUS_OK;
last INCLUDE;
+ } #else we fall through to normal loading.
}
else {
warn($self->error(), "\n");
}
}
(Probably would be good to store the result of the first stat so we aren't
doing 2.)
If the mod times on the two files are the same, then checking that with '=='
rather than '<=' might actually be the better way to do things since we don't
have to eval the compiled file first.
-- Josh
_______________________________________________
templates mailing list
templates@template-toolkit.org
http://lists.template-toolkit.org/mailman/listinfo/templates