Changeset 1779

Show
Ignore:
Timestamp:
04/05/08 02:21:23 (5 months ago)
Author:
bchoate
Message:

Avoid rebuilding files within the same build operation (particularly helps for date-based archive rebuilds). BugId:69032

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/release-33/lib/MT/CMS/Blog.pm

    r1778 r1779  
    559559    my $done          = 0; 
    560560    my $type          = $order[$next]; 
    561     my $archiver      = $app->publisher->archiver($type); 
     561 
     562    my $pub           = $app->publisher; 
     563    $pub->start_time( $start_time );  # force start time to parameter start_time 
     564 
     565    my $archiver      = $pub->archiver($type); 
    562566    my $archive_label = $archiver ? $archiver->archive_label : ''; 
    563567 
  • branches/release-33/lib/MT/FileMgr.pm

    r1174 r1779  
    3636sub delete; 
    3737sub content_is_updated { 1 } 
     38sub file_mod_time { undef } 
    3839 
    3940sub is_handle { 
  • branches/release-33/lib/MT/FileMgr/Local.pm

    r1174 r1779  
    120120} 
    121121 
     122sub file_mod_time { 
     123    my $fmgr = shift; 
     124    my ($file) = @_; 
     125    if (-e $file) { 
     126        return (stat($file))[9]; # modification timestamp 
     127    } 
     128    return undef; 
     129} 
     130 
    122131sub content_is_updated { 
    123132    my $fmgr = shift; 
  • branches/release-33/lib/MT/WeblogPublisher.pm

    r1754 r1779  
    2929    my $this  = {@_}; 
    3030    my $cfg   = MT->config; 
     31    if ( !exists $this->{start_time} ) { 
     32        $this->{start_time} = time; 
     33    } 
    3134    if ( !exists $this->{NoTempFiles} ) { 
    3235        $this->{NoTempFiles} = $cfg->NoTempFiles; 
     
    109112    }; 
    110113 
     114} 
     115 
     116sub start_time { 
     117    my $pub = shift; 
     118    $pub->{start_time} = shift if @_; 
     119    return $pub->{start_time}; 
    111120} 
    112121 
     
    809818    } 
    810819 
     820    # Calculate file path and URL for the new entry. 
     821    my $file = File::Spec->catfile( $root_path, $map->{__saved_output_file} ); 
     822 
     823    ## Untaint. We have to assume that we can trust the user's setting of 
     824    ## the archive_path, and nothing else is based on user input. 
     825    ($file) = $file =~ /(.+)/s; 
     826 
     827    # compare file modification time to start of build process. if it 
     828    # is greater than the start_time, then we shouldn't need to build this 
     829    # file again 
     830    my $fmgr = $blog->file_mgr; 
     831    if (my $mod_time = $fmgr->file_mod_time($file)) { 
     832        return 1 if $mod_time >= $mt->start_time; 
     833    } 
     834 
    811835    if ( $archiver->category_based ) { 
    812836        $category = $specifier{Category}; 
     
    850874    local $ctx->{current_timestamp_end} = $end   if $end; 
    851875 
    852     my $fmgr = $blog->file_mgr; 
    853876    $ctx->{__stash}{blog} = $blog; 
    854877 
    855     # Calculate file path and URL for the new entry. 
    856     my $file = File::Spec->catfile( $root_path, $map->{__saved_output_file} ); 
    857878    require MT::FileInfo; 
    858879 
     
    907928    my ($rel_url) = ( $url =~ m|^(?:[^:]*\:\/\/)?[^/]*(.*)| ); 
    908929    $rel_url =~ s|//+|/|g; 
    909  
    910     ## Untaint. We have to assume that we can trust the user's setting of 
    911     ## the archive_path, and nothing else is based on user input. 
    912     ($file) = $file =~ /(.+)/s; 
    913930 
    914931    # Clear out all the FileInfo records that might point at the page