Browse Source

[download] Check for binary empty chunk string correctly (#3277)

- In Py3, the last file chunk is b'' and the file_reader loop never breaks!
- This is causing a wild infinite for loop and making infinite request to the connected FS for the empty chunk string.

- With the fix, it will break correctly after receiving the first empty binary string of file chunk.
Harsh Gupta 2 years ago
parent
commit
aafb87c62a
1 changed files with 1 additions and 1 deletions
  1. 1 1
      desktop/core/src/desktop/lib/export_csvxls.py

+ 1 - 1
desktop/core/src/desktop/lib/export_csvxls.py

@@ -60,7 +60,7 @@ def file_reader(fh):
   """Generator that reads a file, chunk-by-chunk."""
   while True:
     chunk = fh.read(DOWNLOAD_CHUNK_SIZE)
-    if chunk == '':
+    if not chunk:
       fh.close()
       break
     yield chunk