]> sipb.mit.edu Git - ikiwiki.git/blob - doc/bugs/Slow_Filecheck_attachments___34__snails_it_all__34__.mdwn
Merge remote-tracking branch 'remotes/smcv/ready/careful-eval'
[ikiwiki.git] / doc / bugs / Slow_Filecheck_attachments___34__snails_it_all__34__.mdwn
1 Saving a wiki page in ikwiki or 
2 <tt>ikiwiki --setup wiki.setup --rebuild</tt> takes a **dozen minutes** on a tiny tiny wiki (10 user-added pages)!
3
4 I profiled ikiwiki with [[!cpan Devel::SmallProf]] : see [[users/mathdesc]] for details.
5
6 And I came to the conclusion that [[plugins/filecheck]] on attachment was the only cause.
7 It always go the fallback code using time-consuming file even there it's look like it's
8 not successful. 
9
10 <pre>
11  # Get the mime type.
12         #
13         # First, try File::Mimeinfo. This is fast, but doesn't recognise
14         # all files.
15         eval q{use File::MimeInfo::Magic};                    
16         my $mimeinfo_ok=! $@;                                     
17         my $mimetype;
18         if ($mimeinfo_ok) {
19                 my $mimetype=File::MimeInfo::Magic::magic($file);
20         }                                                         
21         
22         # Fall back to using file, which has a more complete
23         # magic database.
24         if (! defined $mimetype) {
25                 open(my $file_h, "-|", "file", "-bi", $file); 
26                 $mimetype=<$file_h>;                                 
27                 chomp $mimetype;                            
28                 close $file_h;                   
29         }
30         if (! defined $mimetype || $mimetype !~s /;.*//) {
31                 # Fall back to default value.
32                 $mimetype=File::MimeInfo::Magic::default($file)
33                         if $mimeinfo_ok; 
34                 if (! defined $mimetype) {
35                         $mimetype="unknown";
36                 }                                                  
37         }        
38 </pre>
39
40 I found on [[plugins/filecheck/discussion/]] what [[users/DavidBremner/]] described as :
41 > no way to detect text/plain using File::MimeInfo::Magic::magic()
42 But I can't figure out if my issue is boarder and includes this or not.. 
43
44 Any ideas , solve :) more that welcome.
45
46 > [[done]], as isbear noted in [[discussion]], there was a bug that
47 > prevented File::MimeInfo::Magic from ever being used. --[[Joey]]