Added conditionals to avoid having to go through prompts for selections when -o|--output-file is specified during restores
This commit is contained in:
parent
77419ccc8f
commit
a18207bd33
14
bucket-tool
14
bucket-tool
@ -568,6 +568,10 @@ def get_entry_by_file (bucket, filenames)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if $CONFIG[:alt_filepath] != ""
|
||||||
|
return entry, $CONFIG[:alt_filepath]
|
||||||
|
end
|
||||||
|
|
||||||
if filename[0] != '/'
|
if filename[0] != '/'
|
||||||
filename = "/#{filename}"
|
filename = "/#{filename}"
|
||||||
end
|
end
|
||||||
@ -578,6 +582,12 @@ end
|
|||||||
def get_entry_by_hash (bucket)
|
def get_entry_by_hash (bucket)
|
||||||
if bucket.entries.has_key? $CONFIG[:search_term]
|
if bucket.entries.has_key? $CONFIG[:search_term]
|
||||||
entry = bucket.entries[$CONFIG[:search_term]]
|
entry = bucket.entries[$CONFIG[:search_term]]
|
||||||
|
|
||||||
|
if $CONFIG[:alt_filepath] != ""
|
||||||
|
log "$CONFIG[:alt_filepath] was set. Skipping prompts asking for filepaths"
|
||||||
|
return entry, $CONFIG[:alt_filepath]
|
||||||
|
end
|
||||||
|
|
||||||
filepath = ""
|
filepath = ""
|
||||||
if entry.filepaths.count == 1
|
if entry.filepaths.count == 1
|
||||||
filepath = entry.filepaths[0]
|
filepath = entry.filepaths[0]
|
||||||
@ -605,10 +615,6 @@ def restore_entry (bucket)
|
|||||||
entry, filepath = get_entry_by_hash bucket
|
entry, filepath = get_entry_by_hash bucket
|
||||||
end
|
end
|
||||||
|
|
||||||
if $CONFIG[:alt_filepath] != ""
|
|
||||||
filepath=$CONFIG[:alt_filepath]
|
|
||||||
end
|
|
||||||
|
|
||||||
if get_verification "Are you sure you want to overwrite #{filepath}?"
|
if get_verification "Are you sure you want to overwrite #{filepath}?"
|
||||||
File.open(filepath,'w') do |file|
|
File.open(filepath,'w') do |file|
|
||||||
file.write(entry.content)
|
file.write(entry.content)
|
||||||
|
Loading…
Reference in New Issue
Block a user