Preparing search index...

    Function cleanupOrphanedImages

    • Removes image files from the app directory that are no longer referenced by any recipe

      Compares the files present on disk in the permanent storage directory against the set of active image URIs supplied by the caller (typically all image_Source values from the recipe table). Any file not in the active set is deleted.

      Active URIs are normalised before comparison:

      • Empty strings and temporary (cache) URIs are ignored
      • Query parameters (e.g. ?v=123) are stripped

      Parameters

      • activeImageUris: string[]

        Image URIs currently referenced by recipes

      Returns Promise<number>

      Number of orphaned files that were identified and cleaned up

      const deleted = await cleanupOrphanedImages(recipes.map(r => r.image_Source));
      console.log(`Cleaned up ${deleted} orphaned images`);