summaryrefslogtreecommitdiff
path: root/larch
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2012-04-23 07:25:12 +0100
committerLars Wirzenius <liw@liw.fi>2012-04-23 07:25:12 +0100
commit004ea287a08e67f8a8768e7374cd0f15e26f1e85 (patch)
treed2bf4172aa0a0aaada72311acbb2fadb99b76f0b /larch
parent83cc4feaa19367527076c9840f6aaae72f7922c8 (diff)
downloadlarch-004ea287a08e67f8a8768e7374cd0f15e26f1e85.tar.gz
Remove creates flag file, instead of moving actual file
This should be less error prone.
Diffstat (limited to 'larch')
-rw-r--r--larch/journal.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/larch/journal.py b/larch/journal.py
index 5afb810..9636c24 100644
--- a/larch/journal.py
+++ b/larch/journal.py
@@ -40,18 +40,18 @@ class Journal(object):
* ``x`` is the real filename
* ``new/x`` is a new or modified file
- * ``delete/x`` is a deleted file, moved there immediately
+ * ``delete/x`` is a deleted file, created there as a flag file
Commit does this:
- * for every ``delete/x``, remove it
+ * for every ``delete/x``, remove ``x``
* for every ``new/x`` except ``new/metadata``, move to ``x``
* move ``new/metadata`` to ``metadata``
Rollback does this:
* remove every ``new/x``
- * move every ``delete/x`` to ``x``
+ * remove every ``delete/x``
When a journalled node store is opened, if ``new/metadata`` exists,
the commit happens. Otherwise a rollback happens. This guarantees
@@ -60,6 +60,10 @@ class Journal(object):
We only provide enough of a filesystem interface as is needed by
NodeStoreDisk. For example, we do not care about directory removal.
+ The journal can be opened in read-only mode, in which case it ignores
+ any changes in ``new`` and ``delete``, and does not try to rollback or
+ commit at start.
+
'''
flag_basename = 'metadata'
@@ -136,10 +140,7 @@ class Journal(object):
elif self.fs.exists(deleted):
raise OSError((errno.ENOENT, os.strerror(errno.ENOENT), filename))
else:
- dirname = os.path.dirname(deleted)
- if not self.fs.exists(dirname):
- self.fs.makedirs(dirname)
- self.fs.rename(filename, deleted)
+ self.fs.overwrite_file(deleted, '')
def climb(self, dirname, files_only=False):
basenames = self.fs.listdir(dirname)