From: Lukasz Kosewski Date: Sun, 10 Jan 2010 09:04:17 +0000 (-0500) Subject: Don't try to rename tmpfiles into existing open files. X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=ba74eb4d2619f12a3eb786324fb035a674594a63;p=packages%2Fb%2Fbup.git Don't try to rename tmpfiles into existing open files. Linux and friends have no problem with this, but Windows doesn't allow this without some effort, which we can avoid by... not needing to write to an already-open file. Give index.Reader a 'close' method which identifies and closes any open mmaped files, and make cmd-index.py use this before trying to close a index.Writer instance (which renames a tmpfile into the same file the Reader has mmaped). --- diff --git a/cmd-index.py b/cmd-index.py index e3d1b7b..bf1e503 100755 --- a/cmd-index.py +++ b/cmd-index.py @@ -174,6 +174,7 @@ def update_index(path): if wi.count: mi = index.Writer(indexfile) merge_indexes(mi, ri, wi.new_reader()) + ri.close() mi.close() wi.abort() diff --git a/index.py b/index.py index 9a746eb..3860087 100644 --- a/index.py +++ b/index.py @@ -94,7 +94,7 @@ class Reader: self.writable = True def __del__(self): - self.save() + self.close() def __iter__(self): tstart = int(time.time()) @@ -110,6 +110,12 @@ class Reader: if self.writable: self.m.flush() + def close(self): + self.save() + if self.writable: + self.m.close() + self.writable = False + def filter(self, prefixes): #log("filtering %r\n" % prefixes) paths = reduce_paths(prefixes)