]> git.decadent.org.uk Git - memories.git/blobdiff - Memories/Photo.pm
A few fixes found on Geoff's install. Check the Apache2 thing though!
[memories.git] / Memories / Photo.pm
index a497600105d6461dcc75c12b9f44a8d5fd81a1a7..3af95ce787c57e87ac73b4509b3601af46b63e04 100644 (file)
@@ -1,4 +1,5 @@
 package Memories::Photo;
+use Apache2::Upload;
 use File::Basename;
 use File::Copy;
 use Archive::Any;
@@ -96,7 +97,7 @@ sub upload_file {
     warn "$filename is a $res\n";
     if ($res =~ m{/x-zip} or $offered_name =~ /t(ar\.)?gz$/i) {
         return $self->upload_archive($r, $filename);
-    } elsif ($offered_name =~ /\.(raw|nef)/i) {
+    } elsif ($offered_name =~ /\.(raw|nef|dng|cr2)/i) {
         return $self->upload_raw($r, $filename, $offered_name);
     } elsif ($res =~ m{image/jpeg}) {
         return $self->upload_jpeg($r, $filename, $offered_name);
@@ -145,7 +146,8 @@ sub upload_jpeg {
         rated => 0,
     });
     if (!copy($filename, $photo->path("file"))) {
-        $photo->delete(); die "Couldn't copy photo: $!";
+       warn "Couldn't copy photo to ".$photo->path("file").": $!";
+        $photo->delete(); die;
     }
     my ($x, $y) = dim(image_info($photo->path));
     $photo->x($x); $photo->y($y);
@@ -159,8 +161,10 @@ sub upload_jpeg {
     $photo->make_thumb;
     my $tags = $r->{params}{tags}.join " ", map { qq{"$_"} } $photo->tags_exif;
     $photo->add_tags($tags);
+warn "D";
     $photo->add_to_imageseek_library;
     Memories->zap_cache();
+warn "E";
 
     # Add system tags here
     my $tag = "date:".$photo->shot->ymd;
@@ -346,7 +350,7 @@ sub path {
     if ($scale) { $path .= "$scale/" }
     # Make dir if it doesn't exist, save trouble later
     use File::Path;
-    if ($is_url ne "url") {mkpath($path);}
+    if ($is_url ne "url" and ! -d $path) {mkpath($path) or die "Couldn't make path $path: $!";}
     if ($scale or $is_url ne "url") { 
         $path .= $self->id.".jpg";
     } else {