[ARVADOS] updated: ffa11e9dc42740652da1d8382b89bc7eaaac5e2e

git at public.curoverse.com git at public.curoverse.com
Mon Feb 17 14:33:34 EST 2014


Summary of changes:
 sdk/python/bin/arv-normalize          |    2 +-
 services/api/app/models/collection.rb |   18 ++++++++++++++++--
 2 files changed, 17 insertions(+), 3 deletions(-)

       via  ffa11e9dc42740652da1d8382b89bc7eaaac5e2e (commit)
      from  e05e4cd6106b83aa21ef45a3d6537b89d7f67498 (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 ffa11e9dc42740652da1d8382b89bc7eaaac5e2e
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Mon Feb 17 14:34:41 2014 -0500

    Put some code into collection model to do normalization but I don't think that is the right place for it.

diff --git a/sdk/python/bin/arv-normalize b/sdk/python/bin/arv-normalize
index 0a0adbe..b1a6ca7 100755
--- a/sdk/python/bin/arv-normalize
+++ b/sdk/python/bin/arv-normalize
@@ -11,7 +11,7 @@ import logging
 logger = logging.getLogger(os.path.basename(sys.argv[0]))
 
 parser = argparse.ArgumentParser(
-    description='Normalize contents of a manifest')
+    description='Read manifest on standard input and put normalized manifest on standard output.')
 
 args = parser.parse_args()
 
diff --git a/services/api/app/models/collection.rb b/services/api/app/models/collection.rb
index 03e5e4e..efe41cb 100644
--- a/services/api/app/models/collection.rb
+++ b/services/api/app/models/collection.rb
@@ -61,9 +61,19 @@ class Collection < ArvadosModel
       @files = []
       return
     end
+
+    normalized_manifest = ""
+    IO.popen(['arv-normalize'], 'w+b') do |io|
+      io.write manifest_text
+      io.close_write
+      while buf = io.read(2**20)
+        normalized_manifest += buf
+      end
+    end
+
     @data_size = 0
     @files = []
-    manifest_text.split("\n").each do |stream|
+    normalized_manifest.split("\n").each do |stream|
       toks = stream.split(" ")
 
       stream = toks[0].gsub /\\(\\|[0-7]{3})/ do |escape_sequence|
@@ -94,7 +104,11 @@ class Collection < ArvadosModel
               else $1.to_i(8).chr
               end
             end
-            @files << [stream, filename, re[2].to_i]
+            if @files > 0 and @files[-1][0] == stream and @files[-1][1] == filename
+              @files[-1][2] += re[2].to_i
+            else
+              @files << [stream, filename, re[2].to_i]
+            end
           end
         end
       end

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list