[LON-CAPA-dev] File replication on library server

Mark Lucas lon-capa-dev@mail.lon-capa.org
Tue, 16 Oct 2007 06:59:38 -0400


Hi,

I have a small file download routine that pulls together a zip file of
submissions. This runs fine on an access server, but I tried it this
morning on my library server and it does not work. It seems the files do
not end up in the same place as they do on the access server.

The following chunk of code pulls together uploaded files from students
into one directory. I'm figuring the issue is that in this case, access
to files on the library server does not behave like access on the access
servers. Can someone illuminate me? 8)

Thanks!
Mark

# Get the data
    foreach my $student (@$students) {
        my $domain = $student->{'domain'};
        my $username = $student->{'username'};
        my %history = Apache::lonnet::restore($symb,$courseid,$domain,
$username);
        my $uploadurl=$history{'resource.0.upload.uploadedurl'};
        if ($uploadurl) {
           my $filelocation = &Apache::lonnet::filelocation($uploadurl);
           chop($filelocation);

           if (!-e $filelocation)
{&Apache::lonnet::repcopy($filelocation)};

           my $file1 = $filelocation;
           $file1 =~ s|uploaded|home/httpd/html/userfiles|;
           my @tmp = split(/\./,$file1);
           my $filetype = pop(@tmp);
           $filetype =~ s|/||g;
           my $file2 =
$destination."file".substr("000".$index,-3).".$filetype";
$index++;
           copy($file1,$file2);
        } else {
           $html .= "NO FILE for $username<br/>\n";
        }
    }