Package: openshot-qt / 2.6.1+dfsg1-3

0011-classes-thumbnail-Fix-dangling-filehandles.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
From: "FeRD (Frank Dana)" <ferdnyc@gmail.com>
Date: Thu, 4 Nov 2021 21:52:19 -0400
Subject: classes/thumbnail: Fix dangling filehandles

---
 src/classes/thumbnail.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/classes/thumbnail.py b/src/classes/thumbnail.py
index c31bc7e..c4bdfdf 100644
--- a/src/classes/thumbnail.py
+++ b/src/classes/thumbnail.py
@@ -203,13 +203,13 @@ class httpThumbnailHandler(BaseHTTPRequestHandler):
 
         # Send message back to client
         if os.path.exists(thumb_path):
-            if not only_path:
-                self.wfile.write(open(thumb_path, 'rb').read())
-            else:
+            if only_path:
                 self.wfile.write(bytes(thumb_path, "utf-8"))
+            else:
+                with open(thumb_path, 'rb') as f:
+                    self.wfile.write(f.read())
 
         # Pause processing of request (since we don't currently use thread pooling, this allows
         # the threads to be processed without choking the CPU as much
         # TODO: Make HTTPServer work with a limited thread pool and remove this sleep() hack.
         time.sleep(0.01)
-