summaryrefslogtreecommitdiffstats
path: root/swift/1.4.8/plugins/DiskFile.py
diff options
context:
space:
mode:
authorMohammed Junaid <junaid@redhat.com>2012-05-21 15:47:28 +0530
committerPeter Portante <peter.portante@redhat.com>2013-04-29 16:35:54 -0400
commite625cc40ff7ce5a4155abf39cf40dacd61deaee2 (patch)
treef4596533743ea2b4e111740c1190a98a54a406c6 /swift/1.4.8/plugins/DiskFile.py
parent0eed5dd23439bd9c770a675dbfd12c1353f9a29f (diff)
swift: Passing account name in container_update.
This patch also contains fixes to bugs * 811501 * 812498 * 821310 Also, removed the default set of users in the proxy-server.conf file. Change-Id: Ief83905d10ff7bf7c43685ada4d7f05959cee9d1 BUG: 821310 Signed-off-by: Mohammed Junaid <junaid@redhat.com> Reviewed-on: http://review.gluster.com/3390 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vijay@gluster.com>
Diffstat (limited to 'swift/1.4.8/plugins/DiskFile.py')
-rw-r--r--swift/1.4.8/plugins/DiskFile.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/swift/1.4.8/plugins/DiskFile.py b/swift/1.4.8/plugins/DiskFile.py
index 815e1c3..6f77eaa 100644
--- a/swift/1.4.8/plugins/DiskFile.py
+++ b/swift/1.4.8/plugins/DiskFile.py
@@ -15,6 +15,8 @@
import os
from eventlet import tpool
+from tempfile import mkstemp
+from contextlib import contextmanager
from swift.common.utils import normalize_timestamp, renamer
from swift.plugins.utils import mkdirs, rmdirs, validate_object, \
check_valid_account, create_object_metadata, do_open, \
@@ -294,3 +296,21 @@ class Gluster_DiskFile(DiskFile):
if X_OBJECT_TYPE in self.metadata:
self.metadata.pop(X_OBJECT_TYPE)
+ @contextmanager
+ def mkstemp(self):
+ """Contextmanager to make a temporary file."""
+
+ if not os.path.exists(self.tmpdir):
+ mkdirs(self.tmpdir)
+ fd, tmppath = mkstemp(dir=self.tmpdir)
+ try:
+ yield fd, tmppath
+ finally:
+ try:
+ os.close(fd)
+ except OSError:
+ pass
+ try:
+ os.unlink(tmppath)
+ except OSError:
+ pass