check if dir exists before creating

This commit is contained in:
Espen Antonsen 2009-06-11 14:03:33 +02:00
parent 6509900227
commit e1e6d2248f

View file

@ -77,13 +77,13 @@ class Album < ActiveRecord::Base
private private
def create_folders def create_folders
Dir.mkdir( APP_CONFIG[:photos_path] + self.path ) Dir.mkdir( APP_CONFIG[:photos_path] + self.path ) if !Dir.exists?( APP_CONFIG[:photos_path] + self.path )
Dir.mkdir( APP_CONFIG[:thumbs_path] + self.path ) Dir.mkdir( APP_CONFIG[:thumbs_path] + self.path ) if !Dir.exists?( APP_CONFIG[:photos_path] + self.path )
end end
def destroy_folders def destroy_folders
#puts "DELETE DIRECTORY " + APP_CONFIG[:photos_path] + self.path #puts "DELETE DIRECTORY " + APP_CONFIG[:photos_path] + self.path
Dir.delete( APP_CONFIG[:thumbs_path] + self.path ) if File.exists?( APP_CONFIG[:thumbs_path] + self.path ) Dir.delete( APP_CONFIG[:thumbs_path] + self.path ) if Dir.exists?( APP_CONFIG[:thumbs_path] + self.path )
Dir.delete( APP_CONFIG[:photos_path] + self.path ) if File.exists?( APP_CONFIG[:photos_path] + self.path ) Dir.delete( APP_CONFIG[:photos_path] + self.path ) if Dir.exists?( APP_CONFIG[:photos_path] + self.path )
end end
end end