Attachment 'atomic-current-final.diff'

Download

   1 diff -r 4d601d25eb5a MoinMoin/PageEditor.py
   2 --- a/MoinMoin/PageEditor.py	Mon Sep 17 13:42:09 2007 +0200
   3 +++ b/MoinMoin/PageEditor.py	Wed Sep 19 15:20:18 2007 -0400
   4 @@ -946,6 +946,7 @@ Try a different name.""") % (wikiutil.es
   5          revdir = os.path.join(pagedir, 'revisions')
   6          cfn = os.path.join(pagedir, 'current')
   7          clfn = os.path.join(pagedir, 'current-locked')
   8 +        cltfn = os.path.join(pagedir, 'current-locked.tmp')
   9  
  10          # !!! these log objects MUST be created outside the locked area !!!
  11  
  12 @@ -988,14 +989,33 @@ Try a different name.""") % (wikiutil.es
  13              f = file(clfn)
  14              revstr = f.read()
  15              f.close()
  16 -            rev = int(revstr)
  17 +            try:
  18 +                rev = int(revstr)
  19 +            except ValueError, err:
  20 +                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
  21 +
  22              if not was_deprecated:
  23                  if self.do_revision_backup or rev == 0:
  24                      rev += 1
  25              revstr = '%08d' % rev
  26 -            f = file(clfn, 'w')
  27 -            f.write(revstr+'\n')
  28 -            f.close()
  29 +            # write the actual current marker to a tmpfile
  30 +            try:
  31 +                f = file(cltfn, 'w')
  32 +                f.write(revstr+'\n')
  33 +                f.close()
  34 +            except IOError, err:
  35 +                try:
  36 +                    os.remove(cltfn)
  37 +                except:
  38 +                    pass # we don't care for errors in the os.remove
  39 +                # throw a nicer exception
  40 +                if err.errno == errno.ENOSPC:
  41 +                    raise self.SaveError, _("Cannot save page %s, no storage space left") % self.page_name
  42 +                else:
  43 +                    raise self.SaveError, _("An unknown I/O error occured while saving page %s (errno=%d)") % (self.page_name, err.errno)
  44 +            # atomically put it in place (except on windows)
  45 +            else:
  46 +                filesys.rename(cltfn, clfn)
  47  
  48              if not deleted:
  49                  # save to page file
  50 diff -r 4d601d25eb5a MoinMoin/caching.py
  51 --- a/MoinMoin/caching.py	Mon Sep 17 13:42:09 2007 +0200
  52 +++ b/MoinMoin/caching.py	Wed Sep 19 15:20:18 2007 -0400
  53 @@ -145,7 +145,7 @@ class CacheEntry:
  54                          self.wlock.release()
  55              else:
  56                  self.request.log("Can't acquire write lock in %s" % self.lock_dir)
  57 -        except (pickle.PicklingError, IOError, ValueError), err:
  58 +        except (pickle.PicklingError, OSError, IOError, ValueError), err:
  59              raise CacheError(str(err))
  60  
  61      def remove(self):

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.