Lenson commited on
Commit
daa9bc9
·
1 Parent(s): 5d5f0c9

fix: upload script - use sh -c instead of local in while loop

Browse files
Files changed (1) hide show
  1. .hf/setup.sh +62 -58
.hf/setup.sh CHANGED
@@ -173,72 +173,76 @@ upload_to_supabase() {
173
 
174
  # Upload config directory
175
  if [ -d "/app/config" ]; then
176
- find /app/config -type f | while read -r file; do
177
- local relative_path="config/$(basename "$file")"
178
- local size=$(stat -f%z "$file" 2>/dev/null || stat -c%s "$file" 2>/dev/null)
179
-
180
- if [ "$size" -gt 5000000 ]; then
181
- echo "Skipping large file: $file ($size bytes)"
182
- continue
183
- fi
184
-
185
- # Use PUT to overwrite existing files
186
- if curl -s -X PUT \
187
- -H "Authorization: Bearer $SUPABASE_KEY" \
188
- -H "Content-Type: application/octet-stream" \
189
- --data-binary @"$file" \
190
- "$SUPABASE_URL/storage/v1/object/$SUPABASE_BUCKET/$relative_path" 2>/dev/null; then
191
- echo "Uploaded: $relative_path"
192
- else
193
- echo "Upload failed: $relative_path"
194
- fi
195
- done
 
 
196
  fi
197
 
198
  # Upload prompts subdirectory
199
  if [ -d "/app/config/prompts" ]; then
200
- find /app/config/prompts -type f | while read -r file; do
201
- local relative_path="config/prompts/$(basename "$file")"
202
- local size=$(stat -f%z "$file" 2>/dev/null || stat -c%s "$file" 2>/dev/null)
203
-
204
- if [ "$size" -gt 5000000 ]; then
205
- continue
206
- fi
207
-
208
- # Use PUT to overwrite existing files
209
- if curl -s -X PUT \
210
- -H "Authorization: Bearer $SUPABASE_KEY" \
211
- -H "Content-Type: application/octet-stream" \
212
- --data-binary @"$file" \
213
- "$SUPABASE_URL/storage/v1/object/$SUPABASE_BUCKET/$relative_path" 2>/dev/null; then
214
- echo "Uploaded: $relative_path"
215
- else
216
- echo "Upload failed: $relative_path"
217
- fi
218
- done
 
219
  fi
220
 
221
  # Upload data directory
222
  if [ -d "/app/data" ]; then
223
- find /app/data -type f | while read -r file; do
224
- local relative_path="data/$(basename "$file")"
225
- local size=$(stat -f%z "$file" 2>/dev/null || stat -c%s "$file" 2>/dev/null)
226
-
227
- if [ "$size" -gt 5000000 ]; then
228
- continue
229
- fi
230
-
231
- # Use PUT to overwrite existing files
232
- if curl -s -X PUT \
233
- -H "Authorization: Bearer $SUPABASE_KEY" \
234
- -H "Content-Type: application/octet-stream" \
235
- --data-binary @"$file" \
236
- "$SUPABASE_URL/storage/v1/object/$SUPABASE_BUCKET/$relative_path" 2>/dev/null; then
237
- echo "Uploaded: $relative_path"
238
- else
239
- echo "Upload failed: $relative_path"
240
- fi
241
- done
 
242
  fi
243
  }
244
 
 
173
 
174
  # Upload config directory
175
  if [ -d "/app/config" ]; then
176
+ find /app/config -type f -exec sh -c '
177
+ for file do
178
+ relative_path="config/$(basename "$file")"
179
+ size=$(stat -f%z "$file" 2>/dev/null || stat -c%s "$file" 2>/dev/null)
180
+
181
+ if [ "$size" -gt 5000000 ]; then
182
+ echo "Skipping large file: $file ($size bytes)"
183
+ continue
184
+ fi
185
+
186
+ # Use PUT to overwrite existing files
187
+ if curl -s -X PUT \
188
+ -H "Authorization: Bearer $SUPABASE_KEY" \
189
+ -H "Content-Type: application/octet-stream" \
190
+ --data-binary @"$file" \
191
+ "$SUPABASE_URL/storage/v1/object/$SUPABASE_BUCKET/$relative_path" 2>/dev/null; then
192
+ echo "Uploaded: $relative_path"
193
+ else
194
+ echo "Upload failed: $relative_path"
195
+ fi
196
+ done
197
+ ' sh {} +
198
  fi
199
 
200
  # Upload prompts subdirectory
201
  if [ -d "/app/config/prompts" ]; then
202
+ find /app/config/prompts -type f -exec sh -c '
203
+ for file do
204
+ relative_path="config/prompts/$(basename "$file")"
205
+ size=$(stat -f%z "$file" 2>/dev/null || stat -c%s "$file" 2>/dev/null)
206
+
207
+ if [ "$size" -gt 5000000 ]; then
208
+ continue
209
+ fi
210
+
211
+ if curl -s -X PUT \
212
+ -H "Authorization: Bearer $SUPABASE_KEY" \
213
+ -H "Content-Type: application/octet-stream" \
214
+ --data-binary @"$file" \
215
+ "$SUPABASE_URL/storage/v1/object/$SUPABASE_BUCKET/$relative_path" 2>/dev/null; then
216
+ echo "Uploaded: $relative_path"
217
+ else
218
+ echo "Upload failed: $relative_path"
219
+ fi
220
+ done
221
+ ' sh {} +
222
  fi
223
 
224
  # Upload data directory
225
  if [ -d "/app/data" ]; then
226
+ find /app/data -type f -exec sh -c '
227
+ for file do
228
+ relative_path="data/$(basename "$file")"
229
+ size=$(stat -f%z "$file" 2>/dev/null || stat -c%s "$file" 2>/dev/null)
230
+
231
+ if [ "$size" -gt 5000000 ]; then
232
+ continue
233
+ fi
234
+
235
+ if curl -s -X PUT \
236
+ -H "Authorization: Bearer $SUPABASE_KEY" \
237
+ -H "Content-Type: application/octet-stream" \
238
+ --data-binary @"$file" \
239
+ "$SUPABASE_URL/storage/v1/object/$SUPABASE_BUCKET/$relative_path" 2>/dev/null; then
240
+ echo "Uploaded: $relative_path"
241
+ else
242
+ echo "Upload failed: $relative_path"
243
+ fi
244
+ done
245
+ ' sh {} +
246
  fi
247
  }
248