[ARVADOS] updated: 9b318db813552ab4d3c8e4c904ed32bf03779ef7
git at public.curoverse.com
git at public.curoverse.com
Tue Jan 6 00:12:10 EST 2015
Summary of changes:
services/api/app/models/collection.rb | 9 +++++++++
.../db/migrate/20141208174653_collection_file_names.rb | 17 ++++++++++++++++-
2 files changed, 25 insertions(+), 1 deletion(-)
via 9b318db813552ab4d3c8e4c904ed32bf03779ef7 (commit)
from 840592d4a4e02072c982aeaeab5b38daecfcd840 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 9b318db813552ab4d3c8e4c904ed32bf03779ef7
Author: Radhika Chippada <radhika at curoverse.com>
Date: Tue Jan 6 00:11:26 2015 -0500
4523: update the collection file_names migration script to set the file_names during migration.
diff --git a/services/api/app/models/collection.rb b/services/api/app/models/collection.rb
index 66d7add..5701a1c 100644
--- a/services/api/app/models/collection.rb
+++ b/services/api/app/models/collection.rb
@@ -10,6 +10,7 @@ class Collection < ArvadosModel
before_validation :strip_manifest_text
before_validation :set_portable_data_hash
validate :ensure_hash_matches_manifest_text
+ before_save :set_file_names
# Query only undeleted collections by default.
default_scope where("expires_at IS NULL or expires_at > CURRENT_TIMESTAMP")
@@ -126,6 +127,14 @@ class Collection < ArvadosModel
end
end
+ def set_file_names
+ if self.manifest_text_changed? and self.manifest_text
+ # set file_names to the first 2^16 bytes of manifest_text
+ self['file_names'] = self[:manifest_text][0,2**16]
+ end
+ true
+ end
+
def check_encoding
if manifest_text.encoding.name == 'UTF-8' and manifest_text.valid_encoding?
true
diff --git a/services/api/db/migrate/20141208174653_collection_file_names.rb b/services/api/db/migrate/20141208174653_collection_file_names.rb
index 8b182e9..20b637c 100644
--- a/services/api/db/migrate/20141208174653_collection_file_names.rb
+++ b/services/api/db/migrate/20141208174653_collection_file_names.rb
@@ -1,5 +1,20 @@
class CollectionFileNames < ActiveRecord::Migration
- def change
+ include CurrentApiClient
+
+ def up
add_column :collections, :file_names, :string, :limit => 2**16
+
+ act_as_system_user do
+ Collection.all.each do |c|
+ if c.manifest_text
+ c.file_names = c.manifest_text[0, 2**16]
+ c.save!
+ end
+ end
+ end
+ end
+
+ def down
+ remove_column :collections, :file_names
end
end
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list