[typo] Is there a way to refresh the resource list?

de Villamil Frédéric frederic at de-villamil.com
Sun Mar 14 05:47:56 EDT 2010

Le 7 mars 10 à 20:29, Rick DeNatale a écrit :

> I finally got around to upgrading my blog from Typo 5.3 to Typo  
> 5.4.3 today.
> It seems to be working pretty well, but I notice that if I go to the
> admin > manage > images that only a few of the image files in my
> public/files directory seem to have Resource model instances in the
> database.
> Is there an easy way to rectify this?


I just needed to refresh my resources, so I fixed my script. You need  
the mime-types gem first, then

require 'mime/types'

files = File.join("#{RAILS_ROOT}", "public", "files")

Dir.glob("#{files}/*").select do |file|

  resource = Resource.find_by_filename(File.basename(file))
  next unless resource.nil?

  mime = MIME::Types.type_for(file).to_s.chomp

  Resource.create(:filename => File.basename(file), :mime =>  
mime, :created_at => Time.now)

Frédéric de Villamil
"What's mine is mine. What's yours is still unsetteled" – Go player  
frederic at de-villamil.com                        tel: +33 (0)6 62 19 1337
http://t37.net				             	Typo : http://typosphere.org

More information about the Typo-list mailing list