Attachment '0001-Implement-an-incremental-dump-process-2.patch'

Download

   1 From 2c97ef3abd96219f943251932daf8b6778c0b2d7 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 | 37 ++++++++++++++++++++++++++++++++++++-
   8  1 file changed, 36 insertions(+), 1 deletion(-)
   9 
  10 diff --git a/MoinMoin/script/export/dump.py b/MoinMoin/script/export/dump.py
  11 index d770e5b..c545c1a 100644
  12 --- a/MoinMoin/script/export/dump.py
  13 +++ b/MoinMoin/script/export/dump.py
  14 @@ -12,6 +12,8 @@ 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 @@ -126,6 +128,21 @@ General syntax: moin [options] export dump [dump-options]
  24              help = "User the dump will be performed as (for ACL checks, etc)"
  25          )
  26  
  27 +    def changed_pages(self, request, timestamp):
  28 +        pages = []
  29 +        old_pages = []
  30 +        unreadable_pages = []
  31 +        version = wikiutil.timestamp2version(timestamp)
  32 +        log = editlog.EditLog(request)
  33 +        for line in log:
  34 +            if not request.user.may.read(line.pagename):
  35 +                unreadable_pages.append(line.pagename)
  36 +            elif line.ed_time_usecs < version:
  37 +                old_pages.append(line.pagename)
  38 +            else:
  39 +                pages.append(line.pagename)
  40 +        return (unreadable_pages, old_pages, pages)
  41 +
  42      def mainloop(self):
  43          """ moin-dump's main code. """
  44  
  45 @@ -157,7 +174,25 @@ General syntax: moin [options] export dump [dump-options]
  46          # use this user for permissions checks
  47          request.user = user.User(request, name=self.options.dump_user)
  48  
  49 -        pages = request.rootpage.getPageList(user='') # get list of all pages in wiki
  50 +        timestamp = None
  51 +        timestamp_file = os.path.join(outputdir, 'moin-last-update')
  52 +        try:
  53 +            timestamp = os.stat(timestamp_file).st_mtime
  54 +        except OSError, err:
  55 +            if err.errno == errno.EEXIST:
  56 +                with open(timestamp_file, 'w') as f:
  57 +                    f.write('This is a MoinMoin timestamp file\r\n')
  58 +                    f.write('Please delete it to rebuild all pages\r\n')
  59 +                    f.close()
  60 +            else:
  61 +                script.fatal("Cannot check last update time of '%s'!" % timestamp_file)
  62 +        if timestamp:
  63 +            unreadable, old, pages = self.changed_pages(request, timestamp)
  64 +            touch(timestamp_file)
  65 +            if unreadable or old:
  66 +                script.log('Ignored %s old or unreadable pages' % (len(unreadable) + len(old)))
  67 +        else:
  68 +            pages = request.rootpage.getPageList(user='') # get list of all pages in wiki
  69          pages.sort()
  70          if self.options.page: # did user request a particular page or group of pages?
  71              try:
  72 -- 
  73 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.
  • [get | view] (2013-04-20 12:35:44, 3.0 KB) [[attachment:0001-Implement-an-incremental-dump-process-2.patch]]
  • [get | view] (2013-04-20 12:47:13, 3.0 KB) [[attachment:0001-Implement-an-incremental-dump-process-3.patch]]
  • [get | view] (2013-04-20 12:52:02, 3.1 KB) [[attachment:0001-Implement-an-incremental-dump-process-5.patch]]
  • [get | view] (2013-04-20 15:25:38, 6.3 KB) [[attachment:0001-Implement-an-incremental-dump-process-6.patch]]
  • [get | view] (2013-04-23 14:00:12, 5.8 KB) [[attachment:0001-Implement-an-incremental-dump-process-7.patch]]
  • [get | view] (2014-01-01 11:58:47, 11.4 KB) [[attachment:0001-Implement-an-incremental-dump-process-8.patch]]
  • [get | view] (2014-01-11 01:36:19, 13.1 KB) [[attachment:0001-Implement-an-incremental-dump-process-9.patch]]
  • [get | view] (2013-04-23 01:41:09, 6.3 KB) [[attachment:0001-Implement-an-incremental-dump-process.patch]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.