projects
/
tahoe-lafs
/
tahoe-lafs.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
b949ea4
)
fileutil: add move_into_place(), to perform the standard unix trick of atomically...
author
Brian Warner
<warner@lothar.com>
Thu, 19 Feb 2009 06:13:10 +0000
(23:13 -0700)
committer
Brian Warner
<warner@lothar.com>
Thu, 19 Feb 2009 06:13:10 +0000
(23:13 -0700)
src/allmydata/util/fileutil.py
patch
|
blob
|
history
diff --git
a/src/allmydata/util/fileutil.py
b/src/allmydata/util/fileutil.py
index d8b084cfe1df256e025b11b254ccffad335a7e3f..3e33222ab5513168e0128201052c34c012990448 100644
(file)
--- a/
src/allmydata/util/fileutil.py
+++ b/
src/allmydata/util/fileutil.py
@@
-10,7
+10,7
@@
Futz with files like a pro.
"""
-import exceptions, os, stat, tempfile, time
+import
sys,
exceptions, os, stat, tempfile, time
from twisted.python import log
@@
-195,3
+195,10
@@
def du(basedir):
size += os.path.getsize(fn)
return size
+
+def move_into_place(source, dest):
+ """Atomically replace a file, or as near to it as the platform allows.
+ The dest file may or may not exist."""
+ if "win32" in sys.platform.lower():
+ remove_if_possible(dest)
+ os.rename(source, dest)