@@ -80,9 +80,8 @@ def has_data?
8080 end
8181
8282 def reset_to_not_provided!
83- remove_attachment!
8483 update! (
85- status : OperatorDocument . statuses [ :doc_not_provided ] ,
84+ status : OperatorDocument . statuses [ :doc_not_provided ] , attachment : nil ,
8685 expire_date : nil , start_date : nil , uploaded_by : nil , user_id : nil ,
8786 value : nil , link : nil
8887 )
@@ -102,8 +101,8 @@ def move_previous_attachment_to_private_directory
102101 previous_attachment_filename = previous_changes [ :attachment ] [ 0 ]
103102 return if previous_attachment_filename . blank?
104103
105- from = File . join ( attachment . root , attachment . store_dir , previous_attachment_filename )
106- to = from . gsub ( "/public/" , "/private/" )
104+ from = File . join ( attachment . public_root , attachment . store_dir , previous_attachment_filename )
105+ to = File . join ( attachment . private_root , attachment . store_dir , previous_attachment_filename )
107106 FileUtils . makedirs ( File . dirname ( to ) )
108107 system "mv #{ Shellwords . escape ( from ) } #{ Shellwords . escape ( to ) } "
109108 end
@@ -113,9 +112,9 @@ def move_attachment_to_public_directory
113112 attachment_attr = self [ :attachment ]
114113 return if attachment_attr . nil?
115114
116- to = File . join ( attachment . root , attachment . store_dir , attachment_attr )
117- from = to . gsub ( "/public/" , "/private/" )
118- FileUtils . makedirs ( File . dirname ( from ) )
115+ from = File . join ( attachment . private_root , attachment . store_dir , attachment_attr )
116+ to = File . join ( attachment . public_root , attachment . store_dir , attachment_attr )
117+ FileUtils . makedirs ( File . dirname ( to ) )
119118 system "mv #{ Shellwords . escape ( from ) } #{ Shellwords . escape ( to ) } "
120119 end
121120
0 commit comments