Changeset 1372 for branches/release-30/lib/MT/WeblogPublisher.pm
- Timestamp:
- 02/14/08 22:31:01 (22 months ago)
- Files:
-
- 1 modified
-
branches/release-30/lib/MT/WeblogPublisher.pm (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/release-30/lib/MT/WeblogPublisher.pm
r1365 r1372 1210 1210 my ( $blog, $root_path, $map, $at, $ctx, $cond, $build_static, %specifier ) 1211 1211 = @_; 1212 1212 1213 my $finfo; 1213 1214 my $archiver = $mt->archiver($at); … … 1408 1409 return 1 if ( $tmpl->build_dynamic ); 1409 1410 return 1 if ( $entry && $entry->status != MT::Entry::RELEASE() ); 1411 1412 my $timer = MT->get_timer; 1413 if ($timer) { 1414 $timer->pause_partial; 1415 } 1416 local $timer->{elapsed} = 0 if $timer; 1410 1417 1411 1418 if ( … … 1451 1458 1452 1459 $html = $tmpl->build( $ctx, $cond ); 1453 defined($html) 1454 or return $mt->error( 1460 unless (defined($html)) { 1461 $timer->unpause if $timer; 1462 return $mt->error( 1455 1463 ( 1456 1464 $category ? MT->translate( … … 1473 1481 ) 1474 1482 ); 1483 } 1475 1484 my $orig_html = $html; 1476 1485 MT->run_callbacks( … … 1506 1515 ## changed. If not, we won't update the published 1507 1516 ## file, so as not to modify the mtime. 1508 return 1 unless $fmgr->content_is_updated( $file, \$html ); 1517 unless ($fmgr->content_is_updated( $file, \$html )) { 1518 $timer->unpause if $timer; 1519 return 1; 1520 } 1509 1521 1510 1522 ## Determine if we need to build directory structure, … … 1516 1528 unless $path eq '/'; ## OS X doesn't like / at the end in mkdir(). 1517 1529 unless ( $fmgr->exists($path) ) { 1518 $fmgr->mkpath($path) 1519 or return $mt->trans_error( "Error making path '[_1]': [_2]", 1520 $path, $fmgr->errstr ); 1530 if (!$fmgr->mkpath($path)) { 1531 $timer->unpause if $timer; 1532 return $mt->trans_error( "Error making path '[_1]': [_2]", 1533 $path, $fmgr->errstr ); 1534 } 1521 1535 } 1522 1536 … … 1528 1542 my $use_temp_files = !$mt->{NoTempFiles}; 1529 1543 my $temp_file = $use_temp_files ? "$file.new" : $file; 1530 defined( $fmgr->put_data( $html, $temp_file ) ) 1531 or return $mt->trans_error( "Writing to '[_1]' failed: [_2]", 1532 $temp_file, $fmgr->errstr ); 1544 unless ( defined $fmgr->put_data( $html, $temp_file ) ) { 1545 $timer->unpause if $timer; 1546 return $mt->trans_error( "Writing to '[_1]' failed: [_2]", 1547 $temp_file, $fmgr->errstr ); 1548 } 1533 1549 if ($use_temp_files) { 1534 $fmgr->rename( $temp_file, $file ) 1535 or return $mt->trans_error( 1536 "Renaming tempfile '[_1]' failed: [_2]", 1537 $temp_file, $fmgr->errstr ); 1550 if (!$fmgr->rename( $temp_file, $file )) { 1551 $timer->unpause if $timer; 1552 return $mt->trans_error( 1553 "Renaming tempfile '[_1]' failed: [_2]", 1554 $temp_file, $fmgr->errstr ); 1555 } 1538 1556 } 1539 1557 MT->run_callbacks( … … 1568 1586 1569 1587 } 1588 $timer->mark("total:rebuild_file[template_id:" . $tmpl->id . "]") 1589 if $timer; 1570 1590 1; 1571 1591 } … … 1689 1709 $finfo->save(); 1690 1710 } 1711 1712 my $timer = MT->get_timer; 1713 if ($timer) { 1714 $timer->pause_partial; 1715 } 1716 local $timer->{elapsed} = 0 if $timer; 1691 1717 1692 1718 my $ctx = MT::Template::Context->new; … … 1715 1741 1716 1742 my $html = $tmpl->build($ctx); 1717 return $mt->error( $tmpl->errstr ) unless defined $html; 1743 unless (defined $html) { 1744 $timer->unpause if $timer; 1745 return $mt->error( $tmpl->errstr ); 1746 } 1718 1747 1719 1748 my $orig_html = $html; … … 1752 1781 unless $path eq '/'; ## OS X doesn't like / at the end in mkdir(). 1753 1782 unless ( $fmgr->exists($path) ) { 1754 $fmgr->mkpath($path) 1755 or return $mt->trans_error( "Error making path '[_1]': [_2]", 1756 $path, $fmgr->errstr ); 1783 if (! $fmgr->mkpath($path) ) { 1784 $timer->unpause if $timer; 1785 return $mt->trans_error( "Error making path '[_1]': [_2]", 1786 $path, $fmgr->errstr ); 1787 } 1757 1788 } 1758 1789 … … 1760 1791 my $use_temp_files = !$mt->{NoTempFiles}; 1761 1792 my $temp_file = $use_temp_files ? "$file.new" : $file; 1762 defined( $fmgr->put_data( $html, $temp_file ) ) 1763 or return $mt->trans_error( "Writing to '[_1]' failed: [_2]", 1764 $temp_file, $fmgr->errstr ); 1793 unless (defined( $fmgr->put_data( $html, $temp_file ) )) { 1794 $timer->unpause if $timer; 1795 return $mt->trans_error( "Writing to '[_1]' failed: [_2]", 1796 $temp_file, $fmgr->errstr ); 1797 } 1765 1798 if ($use_temp_files) { 1766 $fmgr->rename( $temp_file, $file ) 1767 or 1768 return $mt->trans_error( "Renaming tempfile '[_1]' failed: [_2]", 1769 $temp_file, $fmgr->errstr ); 1799 if (!$fmgr->rename( $temp_file, $file )) { 1800 $timer->unpause if $timer; 1801 return $mt->trans_error( "Renaming tempfile '[_1]' failed: [_2]", 1802 $temp_file, $fmgr->errstr ); 1803 } 1770 1804 } 1771 1805 MT->run_callbacks( … … 1790 1824 file => $file 1791 1825 ); 1826 1827 $timer->mark("total:rebuild_indexes[template_id:" . $tmpl->id . ";file:$file]") 1828 if $timer; 1792 1829 } 1793 1830 1;
