Validate zip file only when there is a uploaded file
authorKarl O. Pinc <kop@karlpinc.com>
Mon, 18 Jan 2021 01:11:14 +0000 (19:11 -0600)
committerKarl O. Pinc <kop@karlpinc.com>
Mon, 18 Jan 2021 01:11:14 +0000 (19:11 -0600)
src/pgwui_bulk_upload/views/bulk_upload.py

index 03a4e8b67f21133599c2550854e3574fd16388b3..ae13dd1a145fb59f5d727b48cf951a96c8265ff5 100644 (file)
@@ -515,6 +515,8 @@ class BulkTableUploadHandler(BaseTableUploadHandler):
         '''Validate the uploaded archive; un-archive it and save
         a path to the decompressed archive.  Return a list of errors.
         '''
+        if self.uf['filename'] == '':
+            return []   # Don't bother, there is no uploaded file
         fh = self.uf['localfh']
         if not zipfile.is_zipfile(fh):
             return [ex.NotAZipfileError(self.uf['filename'])]