From e4a9242adac6217651ea8adfd613cea18634bf05 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Fri, 6 Apr 2018 10:14:17 +0800 Subject: [PATCH] FIX: Can't upload backup. * Regression introduced in https://github.com/discourse/discourse/commit/142571bba010eedbdfc1452d42beccc72389c373 --- app/services/handle_chunk_upload.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/services/handle_chunk_upload.rb b/app/services/handle_chunk_upload.rb index 78f9a343de2..75362e54e59 100644 --- a/app/services/handle_chunk_upload.rb +++ b/app/services/handle_chunk_upload.rb @@ -42,8 +42,11 @@ class HandleChunkUpload tmp_directory = @params[:tmp_directory] # delete destination files - File.delete(upload_path) - File.delete(tmp_upload_path) + begin + File.delete(upload_path) + File.delete(tmp_upload_path) + rescue Errno::ENOENT + end # merge all the chunks File.open(tmp_upload_path, "a") do |file| @@ -59,7 +62,10 @@ class HandleChunkUpload FileUtils.mv(tmp_upload_path, upload_path, force: true) # remove tmp directory - FileUtils.rm_rf(tmp_directory) + begin + FileUtils.rm_rf(tmp_directory) + rescue Errno::ENOENT + end end end