Spaces:
Paused
Paused
Lenson commited on
Commit ·
daa9bc9
1
Parent(s): 5d5f0c9
fix: upload script - use sh -c instead of local in while loop
Browse files- .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
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
|
|
|
|
|
|
| 196 |
fi
|
| 197 |
|
| 198 |
# Upload prompts subdirectory
|
| 199 |
if [ -d "/app/config/prompts" ]; then
|
| 200 |
-
find /app/config/prompts -type f
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
|
|
|
| 219 |
fi
|
| 220 |
|
| 221 |
# Upload data directory
|
| 222 |
if [ -d "/app/data" ]; then
|
| 223 |
-
find /app/data -type f
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
|
|
|
| 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 |
|