$form->tmpl_param("attachment_list" => [attachment_list($form->field('page'))]);
}
-sub attachment_holding_dir {
+sub attachment_holding_location {
my $page=attachment_location(shift);
- return $config{wikistatedir}."/attachments/".
+ my $dir=$config{wikistatedir}."/attachments/".
IkiWiki::possibly_foolish_untaint(linkpage($page));
+ $dir=~s/\/$//;
+ return $dir;
}
-sub remove_held_attachment {
+sub is_held_attachment {
my $attachment=shift;
- my $f=attachment_holding_dir($attachment);
- $f=~s/\/$//;
+ my $f=attachment_holding_location($attachment);
if (-f $f) {
- require IkiWiki::Render;
- IkiWiki::prune($f);
- return 1;
+ return $f
}
else {
- return 0;
+ return undef;
}
}
# Move the attachment into holding directory.
# Try to use a fast rename; fall back to copying.
- my $dest=attachment_holding_dir($form->field('page'));
+ my $dest=attachment_holding_location($form->field('page'));
IkiWiki::prep_writefile($filename, $dest);
unlink($dest."/".$filename);
if (rename($tempfile, $dest."/".$filename)) {
# Move attachments out of holding directory.
my @attachments;
- my $dir=attachment_holding_dir($form->field('page'));
+ my $dir=attachment_holding_location($form->field('page'));
foreach my $filename (glob("$dir/*")) {
next unless -f $filename;
my $dest=$config{srcdir}."/".
}
# attachments in holding directory
- my $dir=attachment_holding_dir($page);
+ my $dir=attachment_holding_location($page);
my $heldmsg=gettext("this attachment is not yet saved");
foreach my $file (glob("$dir/*")) {
- my $mtime=(stat($file))[9];
- my $f=$file;
- $f=~s/^\Q$dir\E\///;
+ next unless -f $file;
+ my $mtime=(stat(_))[9];
+ my $base=IkiWiki::basename($file);
+ my $f=$loc.$base;
$attachments{$f}={
- $std->($page."/".$f, (stat($file))[9], (stat($file))[7]),
- link => "<span title=\"$heldmsg\">$f</span>",
+ $std->($f, (stat($file))[9], (stat(_))[7]),
+ link => "<span title=\"$heldmsg\">$base</span>",
}
}