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).
if wi.count:
mi = index.Writer(indexfile)
merge_indexes(mi, ri, wi.new_reader())
+ ri.close()
mi.close()
wi.abort()
self.writable = True
def __del__(self):
- self.save()
+ self.close()
def __iter__(self):
tstart = int(time.time())
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)