Attachment 'atomic-current-1.5.diff'

Download

   1 # HG changeset patch
   2 # User Antoine Beaupré <anarcat@koumbit.org>
   3 # Date 1190232151 14400
   4 # Node ID 4ca1dc1ddeccbbc2b47a739c427a482394945a0c
   5 # Parent  c8a7086b20c3d523a4331693713515c1dd85d928
   6 backport out-of-space error handling in PageEditor and fix 'current' corruption
   7 
   8 diff -r c8a7086b20c3 -r 4ca1dc1ddecc MoinMoin/PageEditor.py
   9 --- a/MoinMoin/PageEditor.py	Tue Sep 11 18:49:25 2007 +0200
  10 +++ b/MoinMoin/PageEditor.py	Wed Sep 19 16:02:31 2007 -0400
  11 @@ -795,6 +795,7 @@ Try a different name.""") % (wikiutil.es
  12          revdir = os.path.join(pagedir, 'revisions')
  13          cfn = os.path.join(pagedir,'current')
  14          clfn = os.path.join(pagedir,'current-locked')
  15 +        cltfn = os.path.join(pagedir, 'current-locked.tmp')
  16          
  17          # !!! these log objects MUST be created outside the locked area !!!
  18  
  19 @@ -837,14 +838,33 @@ Try a different name.""") % (wikiutil.es
  20                  f = open(clfn)
  21                  revstr = f.read()
  22                  f.close()
  23 -                rev = int(revstr)
  24 +                try:
  25 +                    rev = int(revstr)
  26 +                except ValueError, err:
  27 +                    raise self.SaveError, _("Unabled to determine current page revision from the current page marker. The page %s is damaged and cannot be edited right now.") % self.page_name
  28 +
  29                  if not was_deprecated:
  30                      if self.do_revision_backup or rev == 0:
  31                          rev += 1
  32                  revstr = '%08d' % rev
  33 -                f = open(clfn, 'w')
  34 -                f.write(revstr+'\n')
  35 -                f.close()
  36 +                # write the actual current marker to a tmpfile
  37 +                try:
  38 +                    f = file(cltfn, 'w')
  39 +                    f.write(revstr+'\n')
  40 +                    f.close()
  41 +                except IOError, err:
  42 +                    try:
  43 +                        os.remove(cltfn)
  44 +                    except:
  45 +                        pass # we don't care for errors in the os.remove
  46 +                    # throw a nicer exception
  47 +                    if err.errno == errno.ENOSPC:
  48 +                        raise self.SaveError, _("Cannot save page %s, no storage space left") % self.page_name
  49 +                    else:
  50 +                        raise self.SaveError, _("An unknown I/O error occured while saving page %s (errno=%d)") % (self.page_name, err.errno)
  51 +                # atomically put it in place (except on windows)
  52 +                else:
  53 +                    filesys.rename(cltfn, clfn)
  54                  
  55                  # save to page file
  56                  pagefile = os.path.join(revdir, revstr)

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] (2007-09-19 20:02:54, 2.6 KB) [[attachment:atomic-current-1.5.diff]]
  • [get | view] (2007-09-19 19:20:33, 2.6 KB) [[attachment:atomic-current-final.diff]]
  • [get | view] (2007-09-18 00:17:05, 0.7 KB) [[attachment:warn.diff]]
 All files | Selected Files: delete move to page copy to page

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