durusmail: durus-users: Pack problem on Windows
Pack problem on Windows
Pack problem on Windows
Patrick K. O'Brien
2005-07-06
The patch below allows pack() to work properly on Windows.  Windows
won't let you use rename() to replace an existing file, which is the
case when you run pack() for a second time (the previous prepack_name
file is still out there).  So the existing code results in the following
error:

  OSError: [Errno 17] File exists

Let me know if you need anything else.

Index: file_storage.py
===================================================================
--- file_storage.py     (revision 684)
+++ file_storage.py     (working copy)
@@ -263,6 +263,8 @@
             packed.close()
         unlock_file(self.fp)
         self.fp.close()
+        if os.path.exists(prepack_name):
+            os.unlink(prepack_name)
         os.rename(self.filename, prepack_name)
         os.rename(pack_name, self.filename)
         if RENAME_OPEN_FILE:

--
Patrick K. O'Brien
Orbtech    http://www.orbtech.com
Schevo     http://www.schevo.org
Pypersyst  http://www.pypersyst.org

reply