Skip to main content

Image Size Metadata Fix

Problem Description

In early versions of ImageFlow, the image list API returned the file size field as 0B, causing incorrect display on the frontend.

What’s Fixed

  1. Backend fix: updated listImagesFromRedis in handlers/list.go to read the actual file size from the filesystem.
  2. Standalone migration tool: a dedicated binary under migrate-tool/ to backfill historical file size metadata in bulk.

How to Use

1. Rebuild the application

go build -o imageflow

2. Build and run the migration tool

# Go to the migration tool directory
cd migrate-tool/

# Build binaries for all platforms
./build.sh

# Run the migration (pick your OS)
# Linux
./bin/run-linux.sh

# macOS
./bin/run-macos.sh

# Windows
bin\\run-windows.bat

3. Restart the ImageFlow service

# Using systemd
sudo systemctl restart imageflow

# Using Docker
docker-compose restart

# Run directly
./imageflow

Legacy Version Fix Guidance

Use this guide if your legacy deployment shows file size as 0B in the image list API, and you need to update historical data after upgrading.
  • When to use:
    • The size/file size shown in the admin UI or the image list API is always 0B.
    • Historical metadata is missing or hasn’t recorded file size properly.
  • Remediation path:
    • Upgrade backend: first deploy the backend version that includes the filesystem-based file size read logic and rebuild.
    • Migrate historical data: use the migration tool (see above) to backfill file sizes in bulk.
  • Recommended steps:
    1. Optional: pause writes (uploads/deletes) during off-peak hours to avoid inconsistencies.
    2. Upgrade and restart the backend service (see “Rebuild the application” and “Restart the ImageFlow service”).
    3. Run the migration tool, wait for completion, and review logs for any failures.
    4. Restart the service again if needed or refresh the admin UI to verify the latest data.
  • Verify the fix:
    • Refresh the admin list; sampled images should no longer show 0B.
    • Compare displayed size with the filesystem (e.g., ls -lh).
  • Notes:
    • Make backups before migration (Redis/metadata store and image directories).
    • Ensure the migration tool uses the same environment/configuration (.env, LOCAL_STORAGE_PATH, or storage credentials) and run it in the same environment/container.
    • For containerized deployments, mount the same volumes and ensure proper network access.
  • Troubleshooting:
    • Still 0B after migration: ensure the backend includes the fix and clear frontend caches, then retry.
    • File not found/path mismatch: verify LOCAL_STORAGE_PATH or storage config matches production.
    • Migration tool cannot reach cache/metadata store: double-check endpoints, credentials, and network reachability.
I