# File lib/fastcst/command/mail.rb, line 227
227:         def load_save_changeset(msg)
228:             md_fname = nil
229:             data_file = nil
230:             journal_file = nil
231:             
232:             # body is an array of Message objects for each part
233:             parts = msg.body
234:                         
235:             # first element should be the meta-data YAML
236:             md_part = parts.shift
237:             md = YAML.load(md_part.body)
238:             md_fname = md_part.header[Distribution::X_FASTCST_MD_NAME]
239: 
240:             UI.event :file, "Saving meta-data file #{md_fname}"
241:             File.open(md_fname, "w") { |f| f.write(md_part.body) }
242:                         
243:             # remaining parts should match with contents
244:             parts.each do |part|
245:                 ctype, fname = part.header['Content-Type'].split(';')
246:                 #strip of the name= part
247:                 fname.gsub!("name=", "").strip!
248:                             
249:                 data = Base64.decode64(part.body)
250:                 digest = Digest::MD5.hexdigest(data)
251:                             
252:                 # confirm that the digest matches the meta-data digest
253:                 info = compare_digests(md, fname, digest)
254:                 if info
255:                     UI.event :file, "Matched #{info['Name']} #{info['Digest']}"
256:                     UI.event :file, "Saving file"
257:                     File.open(info['Name'], "w") { |f| f.write data }
258:                     
259:                     case info['Purpose']
260:                     when 'data':
261:                         data_file = info['Name']
262:                     when 'journal':
263:                         journal_file = info['Name']
264:                     end
265:                 else
266:                     UI.failure :file, "NON-MATCHED: #{fname} #{digest}"
267:                 end
268:             end
269: 
270:             return md_fname, data_file, journal_file
271:         end