Item1495: Can't delete an attachment if the physical file is gone for some reason

pencil
Priority: Normal
Current State: Closed
Released In: 1.1.0
Target Release: minor
Applies To: Engine
Component:
Branches:
Reported By: MichaelDaum
Waiting For:
Last Change By: KennethLavrsen
How to repro:

  1. attach a file
  2. remove it on filesystem level
  3. go to delete attachment ... result is During move of attachment pamporn.gif to Trash. an error was found.

It should silently delete the meta data that are left behind even though the attachment itself is gone for some reason (shit happens).

The code calls an attachmentExists() which boils down to a file existence check using -e. That might be too strict. A check for the attachment in the meta data might suffice in this case.

-- MichaelDaum - 22 Apr 2009

An attachment deletion is, by definition, an attachment rename, so let's not think about "delete an attachment" - it just doesn't happen.

So the question is, what is the correct behaviour when you rename an attachment that is listed in topic meta-data, but does not exist in the filestore? There are three choices:
  1. Error out
  2. Silently delete the attachment meta-data. neither old topic nor new topic has the attachment.
  3. Rename the attachment, even though there is no corresponding file on disc
(1) is what we currently do. I do not consider (2) as a realistic option, on the principle of least surprise (shit! my attachment disappeared! what happened?) (3) implies that the existence of an attachment is defined not by its presence in the filestore, but by it's presence in meta-data. The current attachment existence check in the VCStore uses a test of the file on disc, as you observe, to avoid opening the topic to read the meta-data. Other attachment operations are similarly guilty of not reading the topic to recover meta-data so will exhibit similar behaviours.

I am confirming this and dropping the priority to Normal. It's been like that since god-knows-when, so can hardly be classed as urgent.

-- CrawfordCurrie - 24 Apr 2009

I'd vote for (3) as I fear the performance impact of a "silent delete" whenever that happens.

-- MichaelDaum - 24 Apr 2009

Me too. I checked in an implementation. Try it.

-- CrawfordCurrie - 24 Apr 2009

Sterling.

-- MichaelDaum - 24 Apr 2009

I wish. Z$ is more accurate.

-- CrawfordCurrie - 24 Apr 2009

ItemTemplate edit

Summary Can't delete an attachment if the physical file is gone for some reason
ReportedBy MichaelDaum
Codebase
SVN Range Foswiki-1.0.0, Thu, 08 Jan 2009, build 1878
AppliesTo Engine
Component
Priority Normal
CurrentState Closed
WaitingFor
Checkins distro:071aac8c87df
TargetRelease minor
ReleasedIn 1.1.0
Topic revision: r10 - 04 Oct 2010, KennethLavrsen
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy