[LON-CAPA-cvs] cvs: loncom /interface multidownload.pl

banghart lon-capa-cvs-allow@mail.lon-capa.org
Mon, 30 Apr 2007 22:47:31 -0000


banghart		Mon Apr 30 18:47:31 2007 EDT

  Modified files:              
    /loncom/interface	multidownload.pl 
  Log:
  	Make zip output unique.
  
  
Index: loncom/interface/multidownload.pl
diff -u loncom/interface/multidownload.pl:1.22 loncom/interface/multidownload.pl:1.23
--- loncom/interface/multidownload.pl:1.22	Mon Apr 30 14:22:39 2007
+++ loncom/interface/multidownload.pl	Mon Apr 30 18:47:28 2007
@@ -2,7 +2,7 @@
 # CGI-script to allow download of all essay submissions of 
 # multiple students.
 #
-# $Id: multidownload.pl,v 1.22 2007/04/30 18:22:39 banghart Exp $
+# $Id: multidownload.pl,v 1.23 2007/04/30 22:47:28 banghart Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -74,7 +74,7 @@
     my $partlist = $res->parts();
     my ($zipout) = ($symb =~ /^.*\/(.+)\.problem$/);
     $zipout =~ s/\s/_/g;
-    $zipout .= ".zip";
+    $zipout .= "$identifier.zip";
     my $courseid = $env{'request.course.id'};
     my @stuchecked = split(/\n/,$env{'cgi.'.$identifier.'.students'});
     my @parts = split(/\n/,$env{'cgi.'.$identifier.'.parts'});
@@ -125,9 +125,15 @@
     }
     
     &mkpath($doc_zip_root."/zipout/$unique_user",0,0700);
-    my $statement = "cd $doc_zip_root/zipdir/$unique_user/$unique_path\n";
-    $statement .= "zip -r $doc_zip_root/zipout/$unique_user/$zipout * > /dev/null";
-    system($statement);
+    my $statement;
+    if (! -e "$doc_zip_root/zipout/$unique_user/$zipout") {
+        $statement = "cd $doc_zip_root/zipdir/$unique_user/$unique_path\n";
+        $statement .= "zip -r $doc_zip_root/zipout/$unique_user/$zipout * > /dev/null";
+        system($statement);
+    } else {
+        # should happen only if user reloads page 
+        &Apache::lonnet::logthis("$zipout is already there");
+    }
     $statement = "rm -rf $doc_zip_root/zipdir/$unique_user/$unique_path";
     system($statement);
     print('<a href="/zipspool/zipout/'.$unique_user.'/'.$zipout.'">'.