From 8737f9e92a5c9dbf0d75e0702c7ab48f287f2761 Mon Sep 17 00:00:00 2001 From: Chetan Risbud Date: Thu, 1 Aug 2013 19:36:31 +0530 Subject: Handle GET on zero content length failure case. Added a fake_file class that implements minimal set of functions that are invoked by the code in GET. BUG: 987841 https://bugzilla.redhat.com/show_bug.cgi?id=987841 Change-Id: I5bdf5be1c0c4c8231f34c9be529e6edc83774f2e Signed-off-by: Chetan Risbud Reviewed-on: http://review.gluster.org/5511 Reviewed-by: Luis Pabon Tested-by: Luis Pabon --- gluster/swift/common/fs_utils.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'gluster/swift/common/fs_utils.py') diff --git a/gluster/swift/common/fs_utils.py b/gluster/swift/common/fs_utils.py index b2935d0..afc0cfe 100644 --- a/gluster/swift/common/fs_utils.py +++ b/gluster/swift/common/fs_utils.py @@ -24,6 +24,23 @@ from gluster.swift.common.exceptions import FileOrDirNotFoundError, \ NotDirectoryError, GlusterFileSystemOSError, GlusterFileSystemIOError +class Fake_file(object): + def __init__(self, path): + self.path = path + + def tell(self): + return 0 + + def read(self, count): + return 0 + + def fileno(self): + return -1 + + def close(self): + pass + + def do_walk(*args, **kwargs): return os.walk(*args, **kwargs) @@ -205,7 +222,7 @@ def do_open(path, flags, **kwargs): def do_close(fd): - if isinstance(fd, file): + if isinstance(fd, file) or isinstance(fd, Fake_file): try: fd.close() except IOError as err: -- cgit