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?



Hello,

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)
end

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

_______________________________________________
Typo-list mailing list
Typo-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/typo-list

Reply via email to