]> sipb.mit.edu Git - ikiwiki.git/blob - doc/bugs/previewing_new_page_can_leave_files_dangling.mdwn
new bug
[ikiwiki.git] / doc / bugs / previewing_new_page_can_leave_files_dangling.mdwn
1 Steps to reproduce:
2
3 1. Make a new post via web interface.
4 2. Use a directive that generates extra files (say, teximg).
5 3. Click cancel.
6
7 What I expect:
8
9 The files that teximg created should (eventually) be removed, along with the whole directory of the non-existant new post.
10
11 What I got:
12
13 I refresh and rebuild a few times, and the files are still dangling there.  If I then try to create a post with the same name and same content, I get a "file independently created, not overwriting" error.
14
15 > This is specific to previewing when creating a new page. If the page
16 > previously existed, the next update to the page will remove the stale
17 > preview files.
18
19 > Problem is that ikiwiki doesn't store state about files rendered by a
20 > page if the page doesn't exist yet.
21
22 > However, just storing that state wouldn't entirely solve the problem,
23 > since it would still not delete the leftovers until the page is updated,
24 > which it never is if it's previewed and then canceled. And requiring the
25 > cancel button be hit doesn't solve this, because people won't.
26
27 > Also, it's not really ideal that an existing page has to be updated to
28 > remove stale files, because if the edit is aborted, the page might not be
29 > updated for a long time.
30
31 > One fix would be to stash a copy of `%renderedfiles` before generating
32 > the preview, then compare it afterwards to see how it changed and
33 > determine what files were added, and record those someplace, and delete
34 > them on a future refresh (after some reasonable time period). [[done]]
35
36 > Another approach would be to make previewing always render files with
37 > some well-known temporary name. Then all such temp files could be removed
38 > periodically. This would need changes to all plugins that write files
39 > during preview though. For example, `will_render` might be changed to
40 > return the actual filename to write to. --[[Joey]]
41
42 For teximg, I think this can be fixed by using data url like graphviz, but
43 I think plugins in general should be allowed to create files during preview
44 and have them be cleaned up when the user presses cancel.  This segues into
45 what my actual problem is: I wrote a htmlize plugin to format .tex files as
46 page images (following hnb and teximg, since I was completely unfamiliar
47 with perl until yesterday (and ikiwiki until a few days ago)), and there is
48 no way to tell if I'm in preview mode (so I can use data url and not leave
49 files dangling) or commit mode (so I can use real images and not have
50 bloated html).
51
52 > It seems too ugly to thread an indicator to preview mode through to
53 > htmlize, so I'd prefer to not deal with the problem that way.