• Do not register here on develop.twiki.org, login with your twiki.org account.
• Use View topic Item7848 for generic doc work for TWiki-6.1.1. Use View topic Item7851 for doc work on extensions that are not part of a release. More... Close
• Anything you create or change in standard webs (Main, TWiki, Sandbox etc) will be automatically reverted on every SVN update.
Does this site look broken?. Use the LitterTray web for test cases.

Item4631: preserve attachment file time attributes

Item Form Data

AppliesTo: Component: Priority: CurrentState: WaitingFor: TargetRelease ReleasedIn
Extension PublishContrib Enhancement Closed   n/a  

Edit Form Data

Reported By:
Applies To:
Current State:
Waiting For:
Target Release:
Released In:


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:

  1. Delete the contents of {PublishContrib}{Dir}
  2. Publish using PublishContrib
  3. 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

Summary preserve attachment file time attributes
ReportedBy TWiki:Main.DiabJerius
Codebase 4.1.2
SVN Range TWiki-4.2.0, Sat, 08 Sep 2007, build 14780
AppliesTo Extension
Component PublishContrib
Priority Enhancement
CurrentState Closed

Checkins TWikirev:14867
TargetRelease n/a

Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View |  Raw edit | More topic actions
Topic revision: r2 - 2007-09-14 - SteffenPoulsen
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback