Added conditionals to avoid having to go through prompts for selections when -o|--output-file is specified during restores

This commit is contained in:
Tristan Ancelet 2024-05-26 14:27:47 -05:00
parent 77419ccc8f
commit a18207bd33

View File

@ -568,6 +568,10 @@ def get_entry_by_file (bucket, filenames)
end
end
if $CONFIG[:alt_filepath] != ""
return entry, $CONFIG[:alt_filepath]
end
if filename[0] != '/'
filename = "/#{filename}"
end
@ -578,6 +582,12 @@ end
def get_entry_by_hash (bucket)
if bucket.entries.has_key? $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 = ""
if entry.filepaths.count == 1
filepath = entry.filepaths[0]
@ -605,10 +615,6 @@ def restore_entry (bucket)
entry, filepath = get_entry_by_hash bucket
end
if $CONFIG[:alt_filepath] != ""
filepath=$CONFIG[:alt_filepath]
end
if get_verification "Are you sure you want to overwrite #{filepath}?"
File.open(filepath,'w') do |file|
file.write(entry.content)