Not a developer? Go to MovableType.com

Ask an Expert

File timestamp updating

Asked by Charlie Gorichanaz
Posted October 16, 2013, in Featured.

I republished an entire blog, and when I looked at the timestamps on the files, I did not see any recent dates. Does this mean Movable Type could not publish the templates? Or does it not update file timestamps every time a template is republished?

Back

1 Answer

Charlie Gorichanaz

Charlie Gorichanaz on October 16, 2013, 3:57 a.m. Reply

Publishing anything in Movable Type will only result in a changed timestamp if the file actually gets changed. MT compares the rendered template to the existing file and only proceeds to update the file if the two are not identical.

This is true when using static publishing as well as the publishing queue. Static publishing makes use of the rebuild_file and rebuild_indexes subroutines in lib/MT/WeblogPublisher.pm. The publishing queue makes use of the rebuild_from_fileinfo subroutine in the same file, which in turn calls rebuild_file.

In rebuild_file and rebuild_indexes is code like this:

## First check whether the content is actually
## changed. If not, we won't update the published
## file, so as not to modify the mtime.
unless ( $fmgr->content_is_updated( $file, \$html ) ) {
    $timer->unpause if $timer;
    return 1;
}

The content_is_updated subroutine is defined in lib/MT/FileMgr/Local.pm. This checks if the Perl module Digest::MD5 is installed, and if it is, the comparison is done with a MD5 hash of the existing file and rendered template. If the module is not installed, the comparison is done character by character.

Charlie Gorichanaz

Charlie joined Six Apart as a Japan based product manager for Movable Type in February 2014 after spending two years as a developer for 601am. Previously he was the web director of The Badger Herald while studying biochemistry at the University of Wisconsin-Madison.

Website: http://votecharlie.com/
Twitter: @CNG

Ask An Expert