# gnome-vfs and mac os x love to make zero-byte files,
# make them happy
#
- if ($r->headers_in->{'content-length'} == 0) {
+ if ($r->headers_in->{'content-length'} == 0 || $filename =~ /^\.(_|DS_Store)/) {
$dbh->do('DELETE FROM fake_files WHERE expires_at <= now() OR (event=? AND vhost=? AND filename=?);',
undef, $event, $r->get_server_name, $filename)
or dberror($r, "Couldn't prune fake_files");
- $dbh->do('INSERT INTO fake_files (vhost,event,filename,expires_at) VALUES (?,?,?,now() + interval \'30 seconds\');',
+ $dbh->do('INSERT INTO fake_files (vhost,event,filename,expires_at) VALUES (?,?,?,now() + interval \'1 day\');',
undef, $r->get_server_name, $event, $filename)
or dberror($r, "Couldn't add file");
$r->content_type('text/plain; charset="utf-8"');
$dbh->do('INSERT INTO images (id,vhost,event,uploadedby,takenby,filename) VALUES (?,?,?,?,?,?)',
undef, $newid, $r->get_server_name, $event, $user, $takenby, $filename);
- $dbh->do('UPDATE events SET last_update=CURRENT_TIMESTAMP WHERE vhost=? AND event=?',
+ $dbh->do('UPDATE last_picture_cache SET last_update=CURRENT_TIMESTAMP WHERE vhost=? AND event=?',
undef, $r->get_server_name, $event);
+ Sesse::pr0n::Common::purge_cache($r, "/$event/");
# Now save the file to disk
$fname = Sesse::pr0n::Common::get_disk_location($r, $newid);
# Make cache while we're at it.
# Don't do it for the resource forks Mac OS X loves to upload :-(
- if ($filename !~ /^\._/) {
- Sesse::pr0n::Common::ensure_cached($r, $filename, $newid, -1, -1, 1, 80, 64, 320, 256, -1, -1);
+ if ($filename !~ /^\.(_|DS_Store)/) {
+ # FIXME: Ideally we'd want to ensure cache of -1x-1 here as well (for NEFs), but that would
+ # preclude mipmapping in its current form.
+ Sesse::pr0n::Common::ensure_cached($r, $filename, $newid, undef, undef, "nobox", 80, 64, 320, 256);
}
# OK, we got this far, commit
}
}
- # Insert a `shadow file' we can stat the next 30 secs
+ # Insert a `shadow file' we can stat the next day or so
if (defined($autorename) && $autorename eq "autorename/") {
$dbh->do('DELETE FROM shadow_files WHERE expires_at <= now() OR (vhost=? AND event=? AND filename=?);',
undef, $r->get_server_name, $event, $filename)
or dberror($r, "Couldn't prune shadow_files");
- $dbh->do('INSERT INTO shadow_files (vhost,event,filename,id,expires_at) VALUES (?,?,?,?,now() + interval \'30 seconds\');',
+ $dbh->do('INSERT INTO shadow_files (vhost,event,filename,id,expires_at) VALUES (?,?,?,?,now() + interval \'1 day\');',
undef, $r->get_server_name, $event, $orig_filename, $newid)
or dberror($r, "Couldn't add shadow file");
$r->log->info("Added shadow entry for $event/$filename");
my $ref = $q->fetchrow_hashref;
if ($ref->{'cnt'} == 0) {
- my @errors = Sesse::pr0n::Common::add_new_event($dbh, $ne_id, $ne_date, $ne_desc, $r->get_server_name);
+ my @errors = Sesse::pr0n::Common::add_new_event($r, $dbh, $ne_id, $ne_date, $ne_desc);
if (scalar @errors > 0) {
die "Couldn't add new event $ne_id: " . join(', ', @errors);
}
eval {
$dbh->do('INSERT INTO images (id,vhost,event,uploadedby,takenby,filename) VALUES (?,?,?,?,?,?)',
undef, $newid, $r->get_server_name, $event, $user, $takenby, $filename);
- $dbh->do('UPDATE events SET last_update=CURRENT_TIMESTAMP WHERE vhost=? AND event=?',
+ $dbh->do('UPDATE last_picture_cache SET last_update=CURRENT_TIMESTAMP WHERE vhost=? AND event=?',
undef, $r->get_server_name, $event);
# Now save the file to disk
or die "/usr/bin/exifautotran: $!";
# Make cache while we're at it.
- Sesse::pr0n::Common::ensure_cached($r, $filename, $newid, -1, -1, 1, 80, 64, 320, 256, -1, -1);
+ Sesse::pr0n::Common::ensure_cached($r, $filename, $newid, undef, undef, 1, 80, 64, 320, 256, -1, -1);
# OK, we got this far, commit
$dbh->commit;
}
my ($event, $autorename, $filename) = ($1, $2, $3);
- my $sha1 = Digest::SHA1::sha1_base64("/$event/$autorename/$filename");
+ $autorename = '' if (!defined($autorename));
+ my $sha1 = Digest::SHA1::sha1_base64("/$event/$autorename$filename");
$r->status(200);
$r->content_type('text/xml; charset=utf-8');
$dbh->do('DELETE FROM images WHERE vhost=? AND event=? AND filename=?',
undef, $r->get_server_name, $event, $filename)
or dberror($r, "Couldn't remove file");
- $dbh->do('UPDATE events SET last_update=CURRENT_TIMESTAMP WHERE vhost=? AND event=?',
+ $dbh->do('UPDATE last_picture_cache SET last_update=CURRENT_TIMESTAMP WHERE vhost=? AND event=?',
undef, $r->get_server_name, $event)
or dberror($r, "Couldn't invalidate cache");
$r->status(200);