--- loncom/publisher/lonretrieve.pm 2006/04/06 22:15:19 1.30 +++ loncom/publisher/lonretrieve.pm 2006/09/13 21:43:26 1.31 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to retrieve an old version of a file # -# $Id: lonretrieve.pm,v 1.30 2006/04/06 22:15:19 albertel Exp $ +# $Id: lonretrieve.pm,v 1.31 2006/09/13 21:43:26 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -51,19 +51,24 @@ sub phaseone { my $resdir=$resfn; $resdir=~s/\/[^\/]+$/\//; - $fn=~/\/([^\/]+)\.(\w+)$/; - my $main=$1; - my $suffix=$2; - + my ($main,$suffix,$is_meta) = &get_file_info($fn); + if (-e $resfn) { $r->print('
'); @@ -126,14 +140,21 @@ sub phasetwo { } else { $r->print(''.&mt('Copying file').': '); - if (copy($csource,$ctarget)) { + if (copy($csource,$ctarget)) { $r->print('ok
'); print $logfile "Copied sucessfully.\n\n"; } else { @@ -158,6 +179,18 @@ sub phasetwo { } } +sub get_file_info { + my ($fn) = @_; + my ($main,$suffix) = ($fn=~/\/([^\/]+)\.(\w+)$/); + my $is_meta=0; + if ($suffix eq 'meta') { + $is_meta = 1; + ($main,$suffix) = ($main=~/(.+)\.(\w+)$/); + $suffix .= '.meta'; + } + return ($main,$suffix,$is_meta); +} + # ---------------------------------------------------------------- Main Handler sub handler {