Merged in feature/preserve-folder-paths (pull request #179)
support folder paths * support folder paths * s3 storage docs
This commit is contained in:
File diff suppressed because one or more lines are too long
Binary file not shown.
@@ -65,9 +65,9 @@ check_service() {
|
||||
log_info "Service is running"
|
||||
}
|
||||
|
||||
# Create test ZIP file with real PDFs from test.pdf.batch directory
|
||||
# Create test ZIP file with real PDFs from test.pdf.batch directory, each in its own subfolder
|
||||
create_test_zip() {
|
||||
log_info "Creating test ZIP file with real PDFs from ./test.pdf.batch..."
|
||||
log_info "Creating test ZIP file with real PDFs from ./test.pdf.batch, each in its own subfolder..."
|
||||
|
||||
# Remove existing file if it exists
|
||||
rm -f "$ZIP_FILE"
|
||||
@@ -86,14 +86,34 @@ create_test_zip() {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create ZIP file with all PDFs from the batch directory
|
||||
# Create temporary directory structure
|
||||
temp_dir="temp_zip_structure"
|
||||
rm -rf "$temp_dir"
|
||||
mkdir -p "$temp_dir"
|
||||
|
||||
# Copy each PDF to its own subfolder
|
||||
folder_num=1
|
||||
for pdf_file in "$pdf_dir"/*.pdf; do
|
||||
if [ -f "$pdf_file" ]; then
|
||||
folder_name="folder$folder_num"
|
||||
mkdir -p "$temp_dir/$folder_name"
|
||||
cp "$pdf_file" "$temp_dir/$folder_name/"
|
||||
log_info "Placed $(basename "$pdf_file") in $folder_name/"
|
||||
folder_num=$((folder_num + 1))
|
||||
fi
|
||||
done
|
||||
|
||||
# Create ZIP file with the folder structure
|
||||
current_dir=$(pwd)
|
||||
cd "$pdf_dir"
|
||||
zip -q "$current_dir/$ZIP_FILE" *.pdf
|
||||
cd "$temp_dir"
|
||||
zip -q -r "$current_dir/$ZIP_FILE" .
|
||||
cd "$current_dir"
|
||||
|
||||
# Cleanup temporary directory
|
||||
rm -rf "$temp_dir"
|
||||
|
||||
file_size=$(stat -f%z "$ZIP_FILE" 2>/dev/null || stat -c%s "$ZIP_FILE" 2>/dev/null || echo "unknown")
|
||||
log_info "Created $ZIP_FILE with $pdf_count real PDFs ($file_size bytes)"
|
||||
log_info "Created $ZIP_FILE with $pdf_count real PDFs in separate subfolders ($file_size bytes)"
|
||||
}
|
||||
|
||||
# Create client (idempotent)
|
||||
@@ -261,6 +281,7 @@ cancel_batch() {
|
||||
cleanup() {
|
||||
log_info "Cleaning up..."
|
||||
rm -f "$ZIP_FILE" invalid.txt
|
||||
rm -rf temp_zip_structure
|
||||
log_info "Cleanup complete"
|
||||
}
|
||||
|
||||
|
||||
@@ -30,14 +30,38 @@ fi
|
||||
|
||||
echo -e "${GREEN}API is running${NC}"
|
||||
|
||||
# Verify client exists by trying to get its details
|
||||
# Function to create client
|
||||
create_client() {
|
||||
echo "Creating client with ID '$CLIENT_ID'..."
|
||||
CREATE_RESPONSE=$(curl -s -w "\n%{http_code}" -X POST "$API_URL/client" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"id\":\"$CLIENT_ID\",\"name\":\"Test Client $CLIENT_ID\"}")
|
||||
|
||||
CREATE_HTTP_CODE=$(echo "$CREATE_RESPONSE" | tail -n1)
|
||||
CREATE_RESPONSE_BODY=$(echo "$CREATE_RESPONSE" | sed '$d')
|
||||
|
||||
if [ "$CREATE_HTTP_CODE" = "201" ] || [ "$CREATE_HTTP_CODE" = "200" ]; then
|
||||
echo -e "${GREEN}Client '$CLIENT_ID' created successfully${NC}"
|
||||
return 0
|
||||
elif [ "$CREATE_HTTP_CODE" = "409" ] || [ "$CREATE_HTTP_CODE" = "400" ]; then
|
||||
echo -e "${GREEN}Client '$CLIENT_ID' already exists${NC}"
|
||||
return 0
|
||||
else
|
||||
echo -e "${RED}Error: Failed to create client (HTTP $CREATE_HTTP_CODE)${NC}"
|
||||
echo "Response: $CREATE_RESPONSE_BODY"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Verify client exists or create it
|
||||
echo "Verifying client with ID '$CLIENT_ID' exists..."
|
||||
CLIENT_CHECK=$(curl -s -o /dev/null -w "%{http_code}" "$API_URL/client/$CLIENT_ID")
|
||||
|
||||
if [ "$CLIENT_CHECK" != "200" ]; then
|
||||
echo -e "${RED}Error: Client with ID '$CLIENT_ID' not found${NC}"
|
||||
echo "Please ensure the client exists in the database"
|
||||
exit 1
|
||||
echo "Client '$CLIENT_ID' not found, attempting to create it..."
|
||||
if ! create_client; then
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo -e "${GREEN}Client '$CLIENT_ID' verified${NC}"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user