Attachment '0001-Implement-an-incremental-dump-process-5.patch'
Download 1 From 23f8e94e57462dd5cafd4ae10aa8c947fd0efcdb Mon Sep 17 00:00:00 2001
2 From: Paul Wise <pabs3@bonedaddy.net>
3 Date: Sat, 20 Apr 2013 13:46:50 +0800
4 Subject: [PATCH] Implement an incremental dump process
5
6 ---
7 MoinMoin/script/export/dump.py | 39 ++++++++++++++++++++++++++++++++++++++-
8 1 file changed, 38 insertions(+), 1 deletion(-)
9
10 diff --git a/MoinMoin/script/export/dump.py b/MoinMoin/script/export/dump.py
11 index d770e5b..91fa4ac 100644
12 --- a/MoinMoin/script/export/dump.py
13 +++ b/MoinMoin/script/export/dump.py
14 @@ -12,11 +12,16 @@ import sys, os, time, codecs, shutil, re, errno
15 from MoinMoin import config, wikiutil, Page, user
16 from MoinMoin import script
17 from MoinMoin.action import AttachFile
18 +from MoinMoin.logfile import editlog
19 +from MoinMoin.util.filesys import touch
20
21 url_prefix_static = "."
22 logo_html = '<img src="logo.png">'
23 HTML_SUFFIX = ".html"
24
25 +timestamp_text = u'''This is a MoinMoin timestamp file.
26 +Please delete it to rebuild all pages.
27 +'''
28 page_template = u'''<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
29 <html>
30 <head>
31 @@ -126,6 +131,21 @@ General syntax: moin [options] export dump [dump-options]
32 help = "User the dump will be performed as (for ACL checks, etc)"
33 )
34
35 + def changed_pages(self, request, timestamp):
36 + pages = set()
37 + old_pages = set()
38 + unreadable_pages = set()
39 + version = wikiutil.timestamp2version(timestamp)
40 + log = editlog.EditLog(request)
41 + for line in log:
42 + if not request.user.may.read(line.pagename):
43 + unreadable_pages.add(line.pagename)
44 + elif line.ed_time_usecs < version:
45 + old_pages.add(line.pagename)
46 + else:
47 + pages.add(line.pagename)
48 + return (unreadable_pages, old_pages, pages)
49 +
50 def mainloop(self):
51 """ moin-dump's main code. """
52
53 @@ -157,7 +177,24 @@ General syntax: moin [options] export dump [dump-options]
54 # use this user for permissions checks
55 request.user = user.User(request, name=self.options.dump_user)
56
57 - pages = request.rootpage.getPageList(user='') # get list of all pages in wiki
58 + timestamp = None
59 + timestamp_file = os.path.join(outputdir, 'moin-last-update')
60 + try:
61 + timestamp = os.stat(timestamp_file).st_mtime
62 + except OSError, err:
63 + if err.errno == errno.EEXIST:
64 + with open(timestamp_file, 'w') as f:
65 + f.write(timestamp_text)
66 + else:
67 + script.fatal("Cannot check last update time of '%s'!" % timestamp_file)
68 + if timestamp:
69 + unreadable, old, pages = self.changed_pages(request, timestamp)
70 + pages = list(pages)
71 + touch(timestamp_file)
72 + if unreadable or old:
73 + script.log('Ignored %s old or unreadable pages' % (len(unreadable) + len(old)))
74 + else:
75 + pages = request.rootpage.getPageList(user='') # get list of all pages in wiki
76 pages.sort()
77 if self.options.page: # did user request a particular page or group of pages?
78 try:
79 --
80 1.8.2.1
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.