It would be very helpful if file attachments retained their modification times when copied.
I use a two-stage publish process to ensure that deleted topics and attachments aren't present in the final published site. The process looks like this:
- Delete the contents of {PublishContrib}{Dir}
- Publish using PublishContrib
-
rsync
{PublishContrib}{Dir} to the final destination, using the --delete
flag to ensure that "orphaned" content in the final destination is removed
Because the attachment file access and modification times are not retained
rsync
will always copy the attachments. I can get around this by using the
--checksum
option to
rsync
, but this can be quite expensive (my attachments can be quite large).
Here's a small patch to
file.pm
which copies the access and mod times for files. I didn't do it for directories, because directory times are, in my experience, weird and confusing.
*** file.pm~ 2007-03-26 09:30:18.000000000 -0400
--- file.pm 2007-09-14 11:51:35.000000000 -0400
***************
*** 57,64 ****
sub addFile {
my( $this, $from, $to ) = @_;
my $f = "$this->{web}/$to";
! eval { File::Copy::copy( $from, "$this->{path}/$f" ); };
$this->{logger}->logError($@) if $@;
push( @{$this->{files}}, $f );
}
--- 57,68 ----
sub addFile {
my( $this, $from, $to ) = @_;
my $f = "$this->{web}/$to";
! my $dest = "$this->{path}/$f";
! eval { File::Copy::copy( $from, $dest ); };
$this->{logger}->logError($@) if $@;
+ my @stat = stat( $from );
+ $this->{logger}->logError("Unable to stat $from") unless @stat;
+ utime( @stat[8,9], $dest );
push( @{$this->{files}}, $f );
}
--
TWiki:Main/DiabJerius - 14 Sep 2007
Thanks, very good suggestion.
Patch applied to SVN.
--
TWiki:Main.SteffenPoulsen - 14 Sep 2007