diff options
author | Russ Allbery <rra@cpan.org> | 2022-01-17 11:58:26 -0800 |
---|---|---|
committer | Russ Allbery <rra@cpan.org> | 2022-01-17 11:58:26 -0800 |
commit | d09ba9dda5ecbd064997977ffcc3d344fb021e5f (patch) | |
tree | 3df48f03e5ba8c32ddf1d2ebed68eec1a042f809 /lib | |
parent | e6296f537b3dc6527735d1067ff8e19cdc7b9130 (diff) |
Also copy modification timestamps of files
When copying distribution files with docknot release, also copy the
modification timestamps of those files.
Remove an unnecessary stat from latest_tarball, now that it's used
for more things, and move that stat to App::DocKnot::Release, which
has to do this to copy timestamps anyway.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/App/DocKnot/Release.pm | 12 | ||||
-rw-r--r-- | lib/App/DocKnot/Util.pm | 9 |
2 files changed, 10 insertions, 11 deletions
diff --git a/lib/App/DocKnot/Release.pm b/lib/App/DocKnot/Release.pm index b5d8d83..993c706 100644 --- a/lib/App/DocKnot/Release.pm +++ b/lib/App/DocKnot/Release.pm @@ -20,6 +20,7 @@ use App::DocKnot::Config; use App::DocKnot::Spin::Versions; use App::DocKnot::Util qw(latest_tarball); use Carp qw(croak); +use List::Util qw(min); use Path::Tiny qw(path); ############################################################################## @@ -122,9 +123,16 @@ sub release { } # Copy the new version into place and update the symlinks. + my @times; $current_path->mkpath(); for my $file ($tarball_ref->{files}->@*) { - $self->{distdir}->child($file)->copy($current_path->child($file)); + my $source = $self->{distdir}->child($file); + my $dest = $current_path->child($file); + $source->copy($dest); + my ($atime, $mtime) = $source->stat()->@[8, 9]; + push(@times, $mtime); + utime($atime, $mtime, $dest) + or die "cannot reset timestamps of $dest: $!\n"; my $generic_name = $file; $generic_name =~ s{ \A (\Q$self->{tarname}\E) - [\d.]+ [.] }{$1.}xms; my $generic_path = $current_path->child($generic_name); @@ -136,7 +144,7 @@ sub release { if ($self->{versions}) { my $name = $self->{version_name}; my $version = $tarball_ref->{version}; - my $date = $tarball_ref->{date}; + my $date = min(@times); $self->{versions}->update_version($name, $version, $date); } return; diff --git a/lib/App/DocKnot/Util.pm b/lib/App/DocKnot/Util.pm index ef0ef05..c5593df 100644 --- a/lib/App/DocKnot/Util.pm +++ b/lib/App/DocKnot/Util.pm @@ -49,7 +49,6 @@ sub is_newer { # # Returns: Anonymous hash with the following keys: # version - Latest version found -# date - Date (in seconds since epoch) of oldest file # files - Array of files for that version # or undef if no matching files were found # Throws: Text exception on any error @@ -69,14 +68,10 @@ sub latest_tarball { my $latest = $versions[0][0]; @files = map { $_->[1] } grep { $_->[0] eq $latest } @versions; - # Find the timestamps of those files. - my @times = sort(map { $path->child($_)->stat()->[9] } @files); - # Return the results. #<<< return { version => $latest, - date => $times[0], files => \@files, }; #<<< @@ -174,10 +169,6 @@ valid is a hash with the following keys: =over 4 -=item date - -The timestamp of the oldest file for that version, in seconds since epoch. - =item files The list of files found for that version. |