Item1495: Can't delete an attachment if the physical file is gone for some reason
Priority: Normal
Current State: Closed
Released In: 1.1.0
Target Release: minor
Applies To: Engine
Component:
Branches:
How to repro:
- attach a file
- remove it on filesystem level
- 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:
- Error out
- Silently delete the attachment meta-data. neither old topic nor new topic has the attachment.
- 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