Merge branch '8784-dir-listings'
[arvados.git] / services / api / script / salvage_collection.rb
1 #!/usr/bin/env ruby
2 # Copyright (C) The Arvados Authors. All rights reserved.
3 #
4 # SPDX-License-Identifier: AGPL-3.0
5
6 # Take two input parameters: a collection uuid and reason
7 # Get "src_collection" with the given uuid
8 # Create a new collection with:
9 #   src_collection.manifest_text as "invalid_manifest_text.txt"
10 #   Locators from src_collection.manifest_text as "salvaged_data"
11 # Update src_collection:
12 #   Set src_collection.manifest_text to: ""
13 #   Append to src_collection.name: " (reason; salvaged data at new_collection.uuid)"
14 #   Set portable_data_hash to "d41d8cd98f00b204e9800998ecf8427e+0"
15
16 require 'trollop'
17 require './lib/salvage_collection'
18 include SalvageCollection
19
20 opts = Trollop::options do
21   banner ''
22   banner "Usage: salvage_collection.rb " +
23     "{uuid} {reason}"
24   banner ''
25   opt :uuid, "uuid of the collection to be salvaged.", type: :string, required: true
26   opt :reason, "Reason for salvaging.", type: :string, required: false
27 end
28
29 # Salvage the collection with the given uuid
30 SalvageCollection.salvage_collection opts.uuid, opts.reason