Skip to content

Commit

Permalink
Make sure parent folder exists and is a folder before calling worker.
Browse files Browse the repository at this point in the history
  • Loading branch information
Doug Youch committed Jul 30, 2010
1 parent 1fd3e34 commit da62439
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 5 additions & 2 deletions app/controllers/file_controller.rb
Expand Up @@ -174,8 +174,11 @@ def file_manager_update

def upload

if DomainFile.available_file_storage > 0
@upload_file = DomainFile.create(:filename => params[:upload_file][:filename], :parent_id => params[:upload_file][:parent_id], :creator_id => myself.id, :skip_transform => true, :skip_post_processing => true)
folder = DomainFile.find_by_id params[:upload_file][:parent_id]
folder = nil unless folder.folder?

if DomainFile.available_file_storage > 0 && folder
@upload_file = DomainFile.create(:filename => params[:upload_file][:filename], :parent_id => folder.id, :creator_id => myself.id, :skip_transform => true, :skip_post_processing => true)

worker_key = FileWorker.async_do_work(:domain_file_id => @upload_file.id,
:domain_id => DomainModel.active_domain_id,
Expand Down
6 changes: 5 additions & 1 deletion app/views/file/upload_failed.rjs
@@ -1,2 +1,6 @@

page.replace_html 'upload_progress', '<span style="color:red;">' + 'File storage limit reached'.t + '</span>'
if DomainFile.available_file_storage == 0
page.replace_html 'upload_progress', '<span style="color:red;">' + 'File storage limit reached'.t + '</span>'
else
page.redirect_to :action => 'index'
end

0 comments on commit da62439

Please sign in to comment.