From b8ca05a16c8b8e756ffdf8d1d3b7d99868f0cdbd Mon Sep 17 00:00:00 2001 From: hassaku Date: Wed, 7 Jan 2015 14:48:44 +0900 Subject: [PATCH] Touch an empty file if note doesn't exist. --- app/models/fluentd/setting_archive/backup_file.rb | 2 +- app/models/fluentd/setting_archive/note.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/fluentd/setting_archive/backup_file.rb b/app/models/fluentd/setting_archive/backup_file.rb index f0c310c..b2d2f61 100644 --- a/app/models/fluentd/setting_archive/backup_file.rb +++ b/app/models/fluentd/setting_archive/backup_file.rb @@ -13,7 +13,7 @@ class Fluentd def initialize(file_path, note = nil) @file_path = file_path - @note = note || Note.new(file_path.sub(/#{FILE_EXTENSION}$/, Note::FILE_EXTENSION)) + @note = note || Note.create(file_path.sub(/#{FILE_EXTENSION}$/, Note::FILE_EXTENSION)) end end end diff --git a/app/models/fluentd/setting_archive/note.rb b/app/models/fluentd/setting_archive/note.rb index 0cc12b2..4aee755 100644 --- a/app/models/fluentd/setting_archive/note.rb +++ b/app/models/fluentd/setting_archive/note.rb @@ -9,6 +9,11 @@ class Fluentd new(file_path_of(backup_dir, file_id)) end + def self.create(file_path) + FileUtils.touch(file_path) + new(file_path) + end + def initialize(file_path) @file_path = file_path end