diff --git a/app/controllers/avatar_controller.rb b/app/controllers/avatar_controller.rb index b7dec5453..771a14fe8 100644 --- a/app/controllers/avatar_controller.rb +++ b/app/controllers/avatar_controller.rb @@ -28,6 +28,13 @@ class AvatarController < ApplicationController if @temp_file && (@temp_file.size > 0) diskfile=disk_filename(@source_type,@source_id) @urlfile='/' << File.join("images","avatars",avatar_directory(@source_type),avatar_filename(@source_id,@image_file)) + + # 用户头像上传时进行特别处理 + if @source_type == 'User' + diskfile += "temp" + @urlfile += "temp" + end + logger.info("Saving avatar '#{diskfile}' (#{@temp_file.size} bytes)") path = File.dirname(diskfile) unless File.directory?(path) @@ -96,7 +103,16 @@ class AvatarController < ApplicationController unless diskfile.nil? || diskfile == "" path = File.dirname(diskfile) if File.directory?(path) && File.exist?(diskfile) - File.delete(diskfile) + # 用户头像进行特别处理 + if @source_type == 'User' + diskfile1 = diskfile + 'temp' + File.open(diskfile1, "wb") do |f| + buffer = "DELETE" + f.write(buffer) + end + else + File.delete(diskfile) + end end end rescue e do diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index 0559d1a4a..32ae2efc2 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -76,6 +76,8 @@ class MyController < ApplicationController def account @user = User.current @pref = @user.pref + diskfile = disk_filename('User', @user.id) + diskfile1 = diskfile + 'temp' if request.post? @user.safe_attributes = params[:user] @user.pref.attributes = params[:pref] @@ -97,6 +99,33 @@ class MyController < ApplicationController @se.student_id = params[:no] if params[:no] if @user.save && @se.save + # 头像保存 + if File.exist?(diskfile1) + if File.exist?(diskfile) + File.delete(diskfile) + end + File.open(diskfile1, "rb") do |f| + buffer = f.read(10) + if buffer != "DELETE" + File.open(diskfile1, "rb") do |f1| + File.open(diskfile, "wb") do |f| + buffer = "" + while (buffer = f1.read(8192)) + f.write(buffer) + end + end + end + + # File.rename(diskfile + 'temp',diskfile); + end + end + end + + # 确保文件被删除 + if File.exist?(diskfile1) + File.delete(diskfile1) + end + @user.pref.save @user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : []) set_language_if_valid @user.language @@ -104,8 +133,17 @@ class MyController < ApplicationController redirect_to user_path(@user) return else + # 确保文件被删除 + if File.exist?(diskfile1) + File.delete(diskfile1) + end @user end + else + # 确保文件被删除 + if File.exist?(diskfile1) + File.delete(diskfile1) + end end end diff --git a/app/views/messages/_form.html.erb b/app/views/messages/_form.html.erb index 55aa829c8..047f7d660 100644 --- a/app/views/messages/_form.html.erb +++ b/app/views/messages/_form.html.erb @@ -27,14 +27,15 @@
<%# modify by nwb%>
<% if @message.project %>
- <%= f.select :board_id, boards_options_for_select(@message.project.boards) %>
+ <%= text_area :quote,:quote,:style => 'display:none' %> +
<%= label_tag "message_content", l(:description_message_content), :class => "hidden-for-sighted" %> <%= f.text_area :content, :cols => 80, :rows => 13, :class => 'wiki-edit', :id => 'message_content' %>
diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 224190060..54585e314 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -276,6 +276,7 @@ zh: field_is_default: 默认值 field_tracker: 跟踪 field_subject: 主题 + field_quote: 描述 field_due_date: 计划完成日期 field_assigned_to: 指派给 field_priority: 优先级