6203: Corrected one dumb switched order of if conditions that caused 5s lag!!
[arvados.git] / services / api / app / models / collection.rb
index 51ed7ab7b7e9ba627ec2c981ff80887d0eb11316..422a7ede7376f513e7665984b3e3f2ab272003dc 100644 (file)
@@ -103,7 +103,7 @@ class Collection < ArvadosModel
 
       # Remove any permission signatures from the manifest.
       self[:manifest_text] = self.class.munge_manifest_locators!(self[:manifest_text]) do |match|
-        if not in_old_manifest[match[1]] && !cleared_replication_confirmed
+        if not cleared_replication_confirmed  and not in_old_manifest[match[1]]
           self.replication_confirmed_at = nil
           self.replication_confirmed = nil
           cleared_replication_confirmed = true
@@ -244,7 +244,13 @@ class Collection < ArvadosModel
       end
       new_lines << new_words.join(' ')
     end
-    manifest = new_lines.join("\n")+"\n" if !new_lines.empty?
+
+    if !new_lines.empty?
+      ends_with_newline = manifest.end_with?("\n")
+      manifest = new_lines.join("\n")
+      manifest += "\n" if ends_with_newline
+    end
+
     manifest
   end