[kupfer] templates: Create empty file race-free
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [kupfer] templates: Create empty file race-free
- Date: Thu, 17 Dec 2009 01:34:27 +0000 (UTC)
commit 6cb0b7b062b5d1731737338f36a1f68f074ba0f0
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Thu Dec 17 00:47:58 2009 +0100
templates: Create empty file race-free
When "touching" to create a new file, use a race-free method to avoid
clobbering an existing file (which had very low probability).
kupfer/plugin/templates.py | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/kupfer/plugin/templates.py b/kupfer/plugin/templates.py
index bfc12c0..6da5835 100644
--- a/kupfer/plugin/templates.py
+++ b/kupfer/plugin/templates.py
@@ -58,8 +58,8 @@ class CreateNewDocument (Action):
else:
# create new empty file
filename = unicode(iobj)
- destpath = utils.get_destpath_in_directory(leaf.object, filename)
- open(destpath, "w").close()
+ f, destpath = utils.get_destfile_in_directory(leaf.object, filename)
+ f.close()
return FileLeaf(destpath)
def item_types(self):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]