summaryrefslogtreecommitdiff
path: root/doc/bugs/filecheck_failing_to_find_files.mdwn
blob: 6501508e47afc879f665320a39292826333f34ea (plain)

Using the attachment plugin, when filecheck was checking the mime-type of the attachment before allowing the attachment to be removed, it was returning with an error saying that the mime-type of the file was "unknown" (when the mime-type definitely was known!)

It turns out that the filecheck plugin couldn't find the file, because it was merely using the $pagesources hash, rather than finding the absolute path of the file in question.

I don't understand why the file was not in %pagesources. Do you? --[[Joey]]

The file was in %pagesources, but what returns from that is the filename relative to the srcdir directory; for example, foo/bar.gif. When File::MimeInfo::Magic::magic is given that, it can't find the file. But if it is given /path/to/srcdir/foo/bar.gif instead, then it can find the file, and returns the mime-type correctly. --[[KathrynAndersen]]

Ok, so it's not removal specific, can in fact be triggered by using testpagespec (or really anything besides attachment, which passes the filename parameter). Nor is it limited to mimetype, all the tests in filecheck have the problem. --[[Joey]]

Alas, not fixed. It seems I was mistaken in some of my assumptions. It still happens when attempting to remove attachments. With your fix, the IkiWiki::srcfile function is only called when the filename is not passed in, but it appears that in the case of removing attachments, the filename IS passed in, but it is the relative filename as mentioned above. Thus, the file is still not found, and the mime-type comes back as unknown. The reason my patch worked is because, rather than checking whether a filename was passed in before applying IkiWiki::srcfile to the filename, it checks whether the file can be found, and if it cannot be found, then it applies IkiWiki::srcfile to the filename. --[[KathrynAndersen]]

Can you test if this patch fixes that? --[[Joey]]

Yes, it works! --[[KathrynAndersen]]

applied && [[done]]