class DeleteAssetFileFromNfsWorker
  include Sidekiq::Worker
  sidekiq_options queue: "low_priority"

  def perform(asset_id)
    asset = Asset.find(asset_id)
    if asset.uploaded?
      asset.remove_file!
      FileUtils.rmdir(File.dirname(asset.file.path))
    end
  end
end

class DeleteAssetFileFromNfsWorker
  include Sidekiq::Worker
  sidekiq_options queue: "low_priority"

  def perform(asset_id)
    asset = Asset.find(asset_id)
    asset_path = asset.file.path
    if asset.uploaded?
      asset.remove_file!
      FileUtils.rmdir(File.dirname(asset_path))
    end
  end
end

Save asset path before asset is removed in the DeleteAssetFileFromNfsWorker
Save asset path before asset is removed in the DeleteAssetFileFromNfsWorker

Once the asset was removed the file path no longer existed, so it was unable to
delete it.
