feat: ensure consistent filename IDs across script steps

This commit is contained in:
2026-02-21 18:56:36 +01:00
parent 0d31a6fee8
commit 4de55a9f41

View File

@@ -286,12 +286,15 @@ validate_inputs() {
# OUTPUT FILENAME GENERATION
# ============================================================================
_GENERATED_TIMESTAMP=""
generate_output_filename() {
local suffix="${1:-}"
local timestamp
timestamp=$(date +%Y%m%d_%H%M%S)
if [[ -z "$_GENERATED_TIMESTAMP" ]]; then
_GENERATED_TIMESTAMP=$(date +%Y%m%d_%H%M%S)
fi
local seed_part="${SEED:-0}"
local base="img_${MODEL}_${timestamp}_${seed_part}"
local base="img_${MODEL}_${_GENERATED_TIMESTAMP}_${seed_part}"
if [[ -n "$suffix" ]]; then
echo "${base}_${suffix}.png"
@@ -970,6 +973,9 @@ main() {
# Validate inputs
validate_inputs
# Initialize timestamp for consistent naming across subshells
_GENERATED_TIMESTAMP=$(date +%Y%m%d_%H%M%S)
# Banner
print_banner "${PALETTE} Pivoine Image Generator ${SPARKLES}"
@@ -1044,7 +1050,12 @@ main() {
local base="${OUTPUT_FILE%.*}"
upscale_path="${base}_upscaled.${ext}"
else
upscale_path="$(generate_output_filename "upscaled")"
# Include faceswap in name if it was performed
if [[ -n "${faceswap_path:-}" && -f "${faceswap_path}" ]]; then
upscale_path="$(generate_output_filename "faceswap_upscaled")"
else
upscale_path="$(generate_output_filename "upscaled")"
fi
fi
realesrgan_upscale "$final_input" upscale_path || exit 1