Эх сурвалжийг харах

HUE-2383 [filebrowser] Close file handle in read_contents properly

Ivan Orlov 11 жил өмнө
parent
commit
a0e98774df

+ 3 - 1
apps/filebrowser/src/filebrowser/views.py

@@ -621,6 +621,7 @@ def read_contents(codec_type, path, fs, offset, length):
        Returns: A tuple of codec_type, offset, length and contents read.
     """
     contents = ''
+    fhandle = None
 
     try:
         fhandle = fs.open(path)
@@ -660,7 +661,8 @@ def read_contents(codec_type, path, fs, offset, length):
             contents = _read_simple(fhandle, path, offset, length, stats)
 
     finally:
-        fhandle.close()
+        if fhandle:
+            fhandle.close()
 
     return (codec_type, offset, length, contents)