From: Tom Clegg Date: Thu, 31 Jan 2013 19:45:22 +0000 (-0800) Subject: create content-addressed collections with uuid=locator X-Git-Tag: 1.1.0~3457 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/3623d1e89b3e756c8a558449e6a433744c2015d1 create content-addressed collections with uuid=locator --- diff --git a/app/models/collection.rb b/app/models/collection.rb index 1abe209189..2d9d9f102f 100644 --- a/app/models/collection.rb +++ b/app/models/collection.rb @@ -28,4 +28,23 @@ class Collection < OrvosModel end end end + + def assign_uuid + if self.manifest_text.nil? and self.uuid.nil? + super + elsif self.manifest_text and self.uuid + if self.uuid == Digest::MD5.hexdigest(self.manifest_text) + true + else + errors.add :uuid, 'uuid does not match checksum of manifest_text' + false + end + elsif self.manifest_text + errors.add :uuid, 'checksum for manifest_text not supplied in uuid' + false + else + errors.add :manifest_text, 'manifest_text not supplied' + false + end + end end diff --git a/db/migrate/20130130205749_add_manifest_text_to_collection.rb b/db/migrate/20130130205749_add_manifest_text_to_collection.rb new file mode 100644 index 0000000000..7bcb47a6b8 --- /dev/null +++ b/db/migrate/20130130205749_add_manifest_text_to_collection.rb @@ -0,0 +1,5 @@ +class AddManifestTextToCollection < ActiveRecord::Migration + def change + add_column :collections, :manifest_text, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index 7b8c9a8b39..f2deccbb2a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20130128231343) do +ActiveRecord::Schema.define(:version => 20130130205749) do create_table "api_client_authorizations", :force => true do |t| t.string "api_token", :null => false @@ -59,6 +59,7 @@ ActiveRecord::Schema.define(:version => 20130128231343) do t.integer "redundancy_confirmed_as" t.datetime "updated_at" t.string "uuid" + t.text "manifest_text" end add_index "collections", ["uuid"], :name => "index_collections_on_uuid", :unique => true