bin/bagit in bagit-0.3.5 vs bin/bagit in bagit-0.4.0

- old
+ new

@@ -46,19 +46,23 @@ end ##################################### # commands that don't alter the bag # ##################################### if opts['validate'] - if File.exists?(opts['BAGPATH']+'/bag-info.txt') && File.directory?(opts['BAGPATH']+'/data') && File.exists?(opts['BAGPATH']+'/manifest-md5.txt') || File.exists?(opts['BAGPATH']+'/manifest-sha1.txt') - bag = BagIt::Bag.new(opts['BAGPATH']) - if opts['--oxum'] - logger.info(bag.valid_oxum?.to_s) - else - logger.info(bag.valid?.to_s) - end + bag = BagIt::Bag.new(opts['BAGPATH']) + + if opts['--oxum'] + valid = bag.valid_oxum? else - logger.error("Not a valid bag") + valid = bag.valid? end + + if valid + logger.info(valid) + else + logger.error("#{valid}: #{bag.errors.full_messages.join(', ')}" ) + end + # validation commands MUST NOT change manifest or bag-info files exit end if opts['list']