[ARVADOS] created: 88038b52936824be2bd2127c03d54e647cd1ff7e
git at public.curoverse.com
git at public.curoverse.com
Mon Jun 15 15:04:19 EDT 2015
at 88038b52936824be2bd2127c03d54e647cd1ff7e (commit)
commit 88038b52936824be2bd2127c03d54e647cd1ff7e
Author: radhika <radhika at curoverse.com>
Date: Mon Jun 15 15:02:23 2015 -0400
6277: Add check_manifest_validity before_filter in collection model; however, at the moment, this method always true after logging the validation error.
diff --git a/services/api/Gemfile b/services/api/Gemfile
index 1ce85d8..8f1b687 100644
--- a/services/api/Gemfile
+++ b/services/api/Gemfile
@@ -73,7 +73,7 @@ gem 'faye-websocket'
gem 'themes_for_rails'
-gem 'arvados', '>= 0.1.20150210011250'
+gem 'arvados', '>= 0.1.20150615153458'
gem 'arvados-cli', '>= 0.1.20150128223752'
# pg_power lets us use partial indexes in schema.rb in Rails 3
diff --git a/services/api/Gemfile.lock b/services/api/Gemfile.lock
index 58cd6c1..d671182 100644
--- a/services/api/Gemfile.lock
+++ b/services/api/Gemfile.lock
@@ -35,7 +35,7 @@ GEM
addressable (2.3.8)
andand (1.3.3)
arel (3.0.3)
- arvados (0.1.20150609141135)
+ arvados (0.1.20150615153458)
activesupport (>= 3.2.13)
andand (~> 1.3, >= 1.3.3)
google-api-client (~> 0.6.3, >= 0.6.3)
@@ -44,7 +44,7 @@ GEM
arvados-cli (0.1.20150205181653)
activesupport (~> 3.2, >= 3.2.13)
andand (~> 1.3, >= 1.3.3)
- arvados (~> 0.1, >= 0.1.20150128223554)
+ arvados (~> 0.1, >= 0.1.20150615153458)
curb (~> 0.8)
google-api-client (~> 0.6.3, >= 0.6.3)
json (~> 1.7, >= 1.7.7)
@@ -227,7 +227,7 @@ PLATFORMS
DEPENDENCIES
acts_as_api
andand
- arvados (>= 0.1.20150210011250)
+ arvados (>= 0.1.20150615153458)
arvados-cli (>= 0.1.20150128223752)
coffee-rails (~> 3.2.0)
database_cleaner
diff --git a/services/api/app/models/collection.rb b/services/api/app/models/collection.rb
index 1fa7df6..f7822ec 100644
--- a/services/api/app/models/collection.rb
+++ b/services/api/app/models/collection.rb
@@ -9,6 +9,7 @@ class Collection < ArvadosModel
serialize :properties, Hash
before_validation :check_encoding
+ before_validation :check_manifest_validity
before_validation :check_signatures
before_validation :strip_signatures_and_update_replication_confirmed
validate :ensure_pdh_matches_manifest_text
@@ -192,6 +193,15 @@ class Collection < ArvadosModel
end
end
+ def check_manifest_validity
+ begin
+ Keep::Manifest.validate! manifest_text if manifest_text
+ rescue => e
+ logger.warn e
+ end
+ true
+ end
+
def signed_manifest_text
if has_attribute? :manifest_text
token = current_api_client_authorization.andand.api_token
diff --git a/services/api/test/fixtures/collections.yml b/services/api/test/fixtures/collections.yml
index c42a430..d7f6f92 100644
--- a/services/api/test/fixtures/collections.yml
+++ b/services/api/test/fixtures/collections.yml
@@ -79,7 +79,7 @@ multilevel_collection_1:
modified_by_user_uuid: zzzzz-tpzed-d9tiejq69daie8f
modified_at: 2014-02-03T17:22:54Z
updated_at: 2014-02-03T17:22:54Z
- manifest_text: ". 0:0:file1 0:0:file2 0:0:file3\n./dir1 0:0:file1 0:0:file2 0:0:file3\n./dir1/subdir 0:0:file1 0:0:file2 0:0:file3\n./dir2 0:0:file1 0:0:file2 0:0:file3\n"
+ manifest_text: ". d41d8cd98f00b204e9800998ecf8427e+0 0:0:file1 0:0:file2 0:0:file3\n./dir1 d41d8cd98f00b204e9800998ecf8427e+0 0:0:file1 0:0:file2 0:0:file3\n./dir1/subdir d41d8cd98f00b204e9800998ecf8427e+0 0:0:file1 0:0:file2 0:0:file3\n./dir2 d41d8cd98f00b204e9800998ecf8427e+0 0:0:file1 0:0:file2 0:0:file3\n"
name: multilevel_collection_1
multilevel_collection_2:
diff --git a/services/api/test/helpers/manifest_examples.rb b/services/api/test/helpers/manifest_examples.rb
index 08712eb..5acefe9 100644
--- a/services/api/test/helpers/manifest_examples.rb
+++ b/services/api/test/helpers/manifest_examples.rb
@@ -18,7 +18,7 @@ module ManifestExamples
blocktokens = []
filetokens = []
(1..opts[:files_per_stream]).each do |f|
- filetokens << " #{streamsize}:#{filesize}:file#{f}.txt"
+ filetokens << "#{streamsize}:#{filesize}:file#{f}.txt"
(1..opts[:blocks_per_file]).each do |b|
blocktokens << locator
end
diff --git a/services/api/test/unit/collection_test.rb b/services/api/test/unit/collection_test.rb
index 42748ac..7ce73eb 100644
--- a/services/api/test/unit/collection_test.rb
+++ b/services/api/test/unit/collection_test.rb
@@ -64,10 +64,10 @@ class CollectionTest < ActiveSupport::TestCase
manifest_text = './blurfl d41d8cd98f00b204e9800998ecf8427e+0'
index = 0
while manifest_text.length < manifest_size
- manifest_text += ' ' + "0:0:veryverylongfilename000000000000#{index}.txt\n./subdir1"
+ manifest_text += './subdir1 d41d8cd98f00b204e9800998ecf8427e+0' if index > 0
+ manifest_text += ' ' + "0:0:veryverylongfilename000000000000#{index}.txt\n"
index += 1
end
- manifest_text += "\n"
c = Collection.create(manifest_text: manifest_text)
assert c.valid?
@@ -87,7 +87,7 @@ class CollectionTest < ActiveSupport::TestCase
act_as_system_user do
Collection.create(manifest_text: ". acbd18db4cc2f85cedef654fccc4a4d8+3 0:3:foo\n")
Collection.create(manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n")
- Collection.create(manifest_text: ". 85877ca2d7e05498dd3d109baf2df106+95+A3a4e26a366ee7e4ed3e476ccf05354761be2e4ae at 545a9920 0:95:file_in_subdir1\n./subdir2/subdir3 2bbc341c702df4d8f42ec31f16c10120+64+A315d7e7bad2ce937e711fc454fae2d1194d14d64 at 545a9920 0:32:file1.txt 32:32:file2.txt\n./subdir2/subdir3/subdir4 2bbc341c702df4d8f42ec31f16c10120+64+A315d7e7bad2ce937e711fc454fae2d1194d14d64 at 545a9920 0:32:file3.txt 32:32:file4.txt")
+ Collection.create(manifest_text: ". 85877ca2d7e05498dd3d109baf2df106+95+A3a4e26a366ee7e4ed3e476ccf05354761be2e4ae at 545a9920 0:95:file_in_subdir1\n./subdir2/subdir3 2bbc341c702df4d8f42ec31f16c10120+64+A315d7e7bad2ce937e711fc454fae2d1194d14d64 at 545a9920 0:32:file1.txt 32:32:file2.txt\n./subdir2/subdir3/subdir4 2bbc341c702df4d8f42ec31f16c10120+64+A315d7e7bad2ce937e711fc454fae2d1194d14d64 at 545a9920 0:32:file3.txt 32:32:file4.txt\n")
end
[
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list