check if dir exists before creating

rails2
Espen Antonsen 2009-06-11 14:03:33 +02:00
parent 6509900227
commit e1e6d2248f
1 changed files with 4 additions and 4 deletions

View File

@ -77,13 +77,13 @@ class Album < ActiveRecord::Base
private
def create_folders
Dir.mkdir( APP_CONFIG[:photos_path] + self.path )
Dir.mkdir( APP_CONFIG[:thumbs_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 ) if !Dir.exists?( APP_CONFIG[:photos_path] + self.path )
end
def destroy_folders
#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[:photos_path] + self.path ) if File.exists?( APP_CONFIG[:photos_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 Dir.exists?( APP_CONFIG[:photos_path] + self.path )
end
end