[ARVADOS] updated: 1.3.0-602-g696ee0e5e

Git user git at public.curoverse.com
Wed Mar 27 17:38:24 UTC 2019


Summary of changes:
 .../20190322174136_add_file_info_to_collection.rb   | 21 +++++----------------
 1 file changed, 5 insertions(+), 16 deletions(-)

       via  696ee0e5e854347aeb37bdabe3ae3d7712403d06 (commit)
      from  2a17d214467d5302e97008618ef5f560ff1fd45b (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 696ee0e5e854347aeb37bdabe3ae3d7712403d06
Author: Eric Biagiotti <ebiagiotti at veritasgenetics.com>
Date:   Wed Mar 27 13:27:06 2019 -0400

    14484: Updates the migration to use the sdk for manifest parsing
    
    Arvados-DCO-1.1-Signed-off-by: Eric Biagiotti <ebiagiotti at veritasgenetics.com>

diff --git a/services/api/db/migrate/20190322174136_add_file_info_to_collection.rb b/services/api/db/migrate/20190322174136_add_file_info_to_collection.rb
index e12e508be..a1a436ce5 100755
--- a/services/api/db/migrate/20190322174136_add_file_info_to_collection.rb
+++ b/services/api/db/migrate/20190322174136_add_file_info_to_collection.rb
@@ -2,6 +2,8 @@
 #
 # SPDX-License-Identifier: AGPL-3.0
 
+require "arvados/keep"
+
 class AddFileInfoToCollection < ActiveRecord::Migration
   def do_batch(pdhs)
     pdhs_str = ''
@@ -15,23 +17,10 @@ class AddFileInfoToCollection < ActiveRecord::Migration
     )
 
     collections.rows.each do |row|
-      file_count = 0
-      file_size_total = 0
-      row[1].scan(/\S+/) do |token|
-        is_file = token.match(/^[[:digit:]]+:[[:digit:]]+:/)
-        if is_file
-          _, filesize, filename = token.split(':', 3)
-
-          # Avoid counting empty dir placeholders
-          break if filename == '.' && filesize.zero?
-
-          file_count += 1
-          file_size_total += filesize.to_i
-        end
-      end
+      manifest = Keep::Manifest.new(row[1])
       ActiveRecord::Base.connection.exec_query('BEGIN')
-      ActiveRecord::Base.connection.exec_query("UPDATE collections SET file_count=#{file_count}, "\
-                                               "file_size_total=#{file_size_total} "\
+      ActiveRecord::Base.connection.exec_query("UPDATE collections SET file_count=#{manifest.files_count}, "\
+                                               "file_size_total=#{manifest.files_size} "\
                                                "WHERE portable_data_hash='#{row[0]}'")
       ActiveRecord::Base.connection.exec_query('COMMIT')
     end

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list