From 6b1c8874beb171eec6bc6ddcd45913ffa6da57e8 Mon Sep 17 00:00:00 2001 From: short <> Date: Fri, 16 Sep 2005 00:04:32 +0000 Subject: [PATCH] Fixed "Last-Modified" calculation for all the referenced files. --- Web.pm | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/Web.pm b/Web.pm index ab1646f..57950fa 100644 --- a/Web.pm +++ b/Web.pm @@ -377,6 +377,15 @@ my($in,%args)=@_; return $uri->rel(unparsed_uri()); } +my %path_abs_disk_for_package; # $path_abs_disk_for_package{$W->{"__PACKAGE__"}}{$path_abs_disk}=1; + +sub path_abs_disk_register($) +{ +my($path_abs_disk)=@_; + + $path_abs_disk_for_package{$W->{"__PACKAGE__"}}{$path_abs_disk}=1; +} + # $args{"uri_as_in"}=1 to permit passing URI objects as: $in sub path_abs_disk($%) { @@ -387,7 +396,9 @@ my($in,%args)=@_; cluck if !uri_is_local($uri); my $path=$uri->path(); cluck "URI compatibility: ->path() not w/leading slash of URI \"$uri\"; path: $path" if $path!~m{^/}; - return dir_top_abs_disk().$path; + my $r=dir_top_abs_disk().$path; + path_abs_disk_register $r if !defined $args{"register"} || $args{"register"}; + return $r; } sub fatal (;$); @@ -726,7 +737,7 @@ my($in,%args)=@_; cluck if !uri_is_local $in; my $uri=in_to_uri_abs $in; - my $path_abs_disk=path_abs_disk $uri,%args,"uri_as_in"=>1; + my $path_abs_disk=path_abs_disk $uri,%args,"uri_as_in"=>1,"register"=>0; # Known image extension? return path_web($uri,%args,"uri_as_in"=>1),$path_abs_disk if $uri->path()=~m#$img_variants_re#o; @@ -734,6 +745,7 @@ my($in,%args)=@_; my @nego_variants; for my $var (@img_variants) { my $path_abs_disk_variant=$path_abs_disk.".".$var->{"id"}; + path_abs_disk_register($path_abs_disk_variant); __PACKAGE__->make_file($path_abs_disk_variant); push @nego_variants,negotiate_variant( %$var, @@ -831,12 +843,17 @@ sub last_modified($) my($self)=@_; return if !$packages_used_hash{$W->{"__PACKAGE__"}}{"_done"}; + our %path_abs_disk_registered; + if (!$path_abs_disk_registered{$W->{"__PACKAGE__"}}++) { + for my $package_orig (@{$packages_used_array{$W->{"__PACKAGE__"}}}) { + local $_=$package_orig.".pm"; + s{::}{/}g; + path_abs_disk "/$_","register"=>1; + } + } my $mtime_newest; - for my $package_orig (@{$packages_used_array{$W->{"__PACKAGE__"}}}) { - local $_=$package_orig; - $_.=".pm"; - s{::}{/}g; - my $path_abs_disk=path_abs_disk("/$_"); + for my $path_abs_disk (keys(%{$path_abs_disk_for_package{$W->{"__PACKAGE__"}}})) { +###print STDERR "CHECK:$path_abs_disk\n"; my $mtime=(stat $path_abs_disk)[9]; do { cluck "No mtime for: $path_abs_disk"; next; } if !$mtime; $mtime_newest=$mtime if !$mtime_newest || $mtime_newest<$mtime; -- 1.8.3.1