changeset 191:c3c8fa389ee3

action.refresh: remove only all cachefiles of pagename
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Sat, 19 Jul 2008 10:36:52 +0200
parents 45fcfc007160
children 192f39a549e9
files data/plugin/action/refresh.py
diffstat 1 files changed, 13 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/data/plugin/action/refresh.py	Fri Jul 18 12:58:12 2008 +0200
+++ b/data/plugin/action/refresh.py	Sat Jul 19 10:36:52 2008 +0200
@@ -9,7 +9,7 @@
 """
 import os
 from MoinMoin import config, wikiutil
-from MoinMoin.action import cache
+from MoinMoin.action import AttachFile, cache
 from MoinMoin.Page import Page
 
 def execute(pagename, request):
@@ -25,15 +25,20 @@
     caching.CacheEntry(request, arena, key, scope='item').remove()
     caching.CacheEntry(request, arena, "pagelinks", scope='item').remove()
 
-    # remove cache files from arnica
+    # remove cache files from current page
+    attachment_files = AttachFile._get_files(request, pagename)
     path = caching.CacheEntry(request, cache.cache_arena, "",
                               cache.cache_scope, do_locking=False)._filename()
 
-    files = [fn.decode(config.charset) for fn in os.listdir(path) 
-             if fn.endswith('data') and fn.endswith('meta')]
-    for file_name in files:
-        key, ext = os.path.splitext(file_name)
-        if key.startswith('T') or key.startswith('W'):
-            cache.remove(request, key)
+    key_files = [fn.decode(config.charset) for fn in os.listdir(path)
+                 if fn.endswith('data') or fn.endswith('meta')]
+
+    for attfile in attachment_files:
+        key = cache.key(request, itemname=pagename, attachname=attfile)
+        for file_name in key_files:
+            file, ext = os.path.splitext(file_name)
+            if file.endswith(key):
+                cache.remove(request, file)
+                break
 
     request.page.send_page()