ucalyptus commited on
Commit
a0d7ecf
·
1 Parent(s): 2730a68

first232hjhkhkdsafdssadff

Browse files
Files changed (1) hide show
  1. app.py +21 -2
app.py CHANGED
@@ -20,6 +20,21 @@ def validate_repo_url(url):
20
  except:
21
  return False
22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  def pack_repository(repo_url, branch, output_style, remove_comments, remove_empty_lines, security_check):
24
  """Pack a repository using Repomix and return the output."""
25
  if not repo_url:
@@ -76,7 +91,11 @@ def pack_repository(repo_url, branch, output_style, remove_comments, remove_empt
76
  try:
77
  with open(output_file, 'r', encoding='utf-8') as f:
78
  content = f.read()
79
- return content, content
 
 
 
 
80
  except Exception as e:
81
  return f"Error reading output file: {str(e)}", None
82
 
@@ -140,7 +159,7 @@ with gr.Blocks(title="Repo to TXT", theme=gr.themes.Soft()) as demo:
140
  download_button = gr.File(
141
  label="Download Output",
142
  file_count="single",
143
- type="file",
144
  interactive=False
145
  )
146
 
 
20
  except:
21
  return False
22
 
23
+ def create_download_file(content):
24
+ """Create a temporary file for download and return its path."""
25
+ if not content:
26
+ return None
27
+
28
+ try:
29
+ # Create a temporary file
30
+ temp_file = tempfile.NamedTemporaryFile(delete=False, mode='w', suffix='.txt')
31
+ temp_file.write(content)
32
+ temp_file.close()
33
+ return temp_file.name
34
+ except Exception as e:
35
+ print(f"Error creating download file: {str(e)}")
36
+ return None
37
+
38
  def pack_repository(repo_url, branch, output_style, remove_comments, remove_empty_lines, security_check):
39
  """Pack a repository using Repomix and return the output."""
40
  if not repo_url:
 
91
  try:
92
  with open(output_file, 'r', encoding='utf-8') as f:
93
  content = f.read()
94
+
95
+ # Create a download file and return its path
96
+ download_path = create_download_file(content)
97
+ return content, download_path
98
+
99
  except Exception as e:
100
  return f"Error reading output file: {str(e)}", None
101
 
 
159
  download_button = gr.File(
160
  label="Download Output",
161
  file_count="single",
162
+ type="filepath",
163
  interactive=False
164
  )
165