acecalisto3 commited on
Commit
3a075bd
·
verified ·
1 Parent(s): 45b3c5f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -10
app.py CHANGED
@@ -175,22 +175,21 @@ class FileProcessor:
175
  for file in files:
176
  # Check if the file is a Gradio File object or a string path
177
  file_name = file.name if isinstance(file, gr.File) else file
178
- if os.path.isfile(file_name):
179
- file_size = os.path.getsize(file_name)
180
- if file_size > self.max_file_size:
181
- logger.warning(f"File size ({file_size} bytes) exceeds maximum allowed size")
182
- continue # Skip this file
183
 
184
- if zipfile.is_zipfile(file_name):
185
- combined_data.extend(self._process_zip_file(file_name))
186
- else:
187
- combined_data.extend(self._process_single_file(file_name))
188
  else:
189
- logger.warning(f"Skipping directory: {file_name}")
190
 
191
  except Exception as e:
192
  logger.error(f"Error processing files: {str(e)}")
193
  return []
 
 
194
 
195
  def _process_zip_file(self, zip_path: str) -> List[Dict]:
196
  """Process ZIP file contents"""
 
175
  for file in files:
176
  # Check if the file is a Gradio File object or a string path
177
  file_name = file.name if isinstance(file, gr.File) else file
178
+ file_size = os.path.getsize(file_name)
179
+ if file_size > self.max_file_size:
180
+ logger.warning(f"File size ({file_size} bytes) exceeds maximum allowed size")
181
+ continue # Skip this file
 
182
 
183
+ if zipfile.is_zipfile(file_name):
184
+ combined_data.extend(self._process_zip_file(file_name))
 
 
185
  else:
186
+ combined_data.extend(self._process_single_file(file_name))
187
 
188
  except Exception as e:
189
  logger.error(f"Error processing files: {str(e)}")
190
  return []
191
+ finally:
192
+ return combined_data
193
 
194
  def _process_zip_file(self, zip_path: str) -> List[Dict]:
195
  """Process ZIP file contents"""