FIX: Raise an error if metadata is not extracted correctly.

This commit is contained in:
Guo Xiang Tan 2016-08-25 17:19:10 +08:00
parent 5da768b4fe
commit 7e80810de1
1 changed files with 6 additions and 1 deletions

View File

@ -201,7 +201,9 @@ module BackupRestore
)
end
Oj.load_file(@meta_filename)
data = Oj.load_file(@meta_filename)
raise "Failed to load metadata file." if !data
data
else
if @filename =~ /-#{BackupRestore::VERSION_PREFIX}(\d{14})/
{ "version" => Regexp.last_match[1].to_i }
@ -214,6 +216,9 @@ module BackupRestore
def validate_metadata
log "Validating metadata..."
log " Current version: #{@current_version}"
raise "Metadata has not been extracted correctly." if !@metadata
log " Restored version: #{@metadata["version"]}"
error = "You're trying to restore a more recent version of the schema. You should migrate first!"