From 93893b9ac06479bdfe28f94fce961594b928121a Mon Sep 17 00:00:00 2001 From: Mohammed Junaid Date: Mon, 21 May 2012 15:47:28 +0530 Subject: 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 Reviewed-on: http://review.gluster.com/3390 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- swift/1.4.8/plugins/DiskFile.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'swift/1.4.8/plugins/DiskFile.py') diff --git a/swift/1.4.8/plugins/DiskFile.py b/swift/1.4.8/plugins/DiskFile.py index 815e1c3ab54..6f77eaaa57a 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 -- cgit