mix phx_media_library.clean (PhxMediaLibrary v0.6.1)

Copy Markdown View Source

Cleans up orphaned media files.

This task finds and optionally removes:

  • Files in storage that don't have corresponding database records
  • Database records that don't have corresponding files in storage

Usage

# Show orphaned files (dry run)
$ mix phx_media_library.clean

# Actually delete orphaned files
$ mix phx_media_library.clean --force

# Only check specific disk
$ mix phx_media_library.clean --disk local

# Only clean orphaned files (not database records)
$ mix phx_media_library.clean --files-only

# Only clean orphaned database records (not files)
$ mix phx_media_library.clean --records-only

Options

--force         Actually delete orphaned items (default: dry run)
--disk          Only check this disk
--files-only    Only clean orphaned files
--records-only  Only clean orphaned database records