Commit 04090942 authored by Roque's avatar Roque

always yes mode for uploads and downloads

parent 9de1e703
......@@ -60,11 +60,15 @@ module Embulk
if not conflicts.empty?
puts
@logger.warn("Some of your local files already exist in remote dataset.", print=TRUE)
@logger.warn("You may want to cancel this partial ingestion and download the full dataset to make local changes.", print=TRUE)
if task['always_yes_mode'] != "true"
@logger.warn("You may want to cancel this partial ingestion and download the full dataset to make local changes.", print=TRUE)
end
puts
@logger.warn("Current ingestion WILL OVERWRITE the following files in remote dataset:", print=TRUE)
puts "** press key **"
option = gets
if task['always_yes_mode'] != "true"
puts "** press key **"
option = gets
end
print_short = conflicts.length > 500
@dataset_utils.showChangesList(conflicts, "", print_short, status=DatasetUtils::OVERWRITE)
else
......@@ -85,6 +89,7 @@ module Embulk
if task['chunk_size'] == 0
task['chunk_size'] = DatasetUtils::CHUNK_SIZE
end
task['always_yes_mode'] = config.param('always_yes', :string)
@data_set = task['data_set']
@dataset_utils = DatasetUtils.new("")
paths = config.param('path_prefix', :array)
......@@ -133,7 +138,7 @@ module Embulk
else
if not @dataset_utils.partialIngestionFileExist()
@logger.info("Checking local dataset...", print=TRUE)
if not @dataset_utils.reportUpToDate(data_stream_dict, @data_set)
if not @dataset_utils.reportUpToDate(data_stream_dict, @data_set) and task['always_yes_mode'] != "true"
puts
@logger.error("Your current dataset is outdated. Please, run a download to update it before ingest your changes.", print=TRUE)
puts
......@@ -153,12 +158,14 @@ module Embulk
end
self.status(task, push=TRUE)
@logger.info("Continue with ingestion? (y/n)", print=TRUE)
option = gets
option = option.chomp
if option == "n"
@logger.info("Ingestion cancelled by user.", print=TRUE)
@logger.abortExecution()
if task['always_yes_mode'] != "true"
@logger.info("Continue with ingestion? (y/n)", print=TRUE)
option = gets
option = option.chomp
if option == "n"
@logger.info("Ingestion cancelled by user.", print=TRUE)
@logger.abortExecution()
end
end
if not @dataset_utils.reportFileExist()
@dataset_utils.createReportFile()
......
......@@ -31,6 +31,14 @@ module Embulk
end
end
def self.alwaysYesDownload()
@dataset_utils.deleteSplitOperationControlFile()
@dataset_utils.deleteSplitOperationFile()
@dataset_utils.deleteCompletedFile()
@dataset_utils.createReportFile()
@logger.info("[always yes mode] Download operation will overwrite previous local dataset.", print=TRUE)
end
def self.askUserForAction(task, action, show_message)
option = @dataset_utils.getConfiguration(action, task['tool_dir'])
valid_option = option != DatasetUtils::OPTION_ABORT ? TRUE : FALSE
......@@ -104,7 +112,8 @@ module Embulk
'data_set' => @data_set,
'chunk_size' => DatasetUtils::CHUNK_SIZE + 10,
'output_path' => @output_path,
'tool_dir' => @tool_dir
'tool_dir' => @tool_dir,
'always_yes_mode' => config.param('always_yes', :string)
}
if task['chunk_size'] == 0
task['chunk_size'] = DatasetUtils::CHUNK_SIZE
......@@ -158,10 +167,18 @@ module Embulk
task['data_streams'] = @dataset_utils.getRemoteFileListForDiscardLocalChanges(task['data_streams'], @data_set,
check_changes=FALSE, changes=local_changes)
else
self.askUserForAction(task, action=DatasetUtils::OPTION_UPDATE, show_message=TRUE)
if task['always_yes_mode'] != "true"
self.askUserForAction(task, action=DatasetUtils::OPTION_UPDATE, show_message=TRUE)
else
self.alwaysYesDownload()
end
end
elsif not @dataset_utils.partialIngestionFileExist()
self.askUserForAction(task, action=DatasetUtils::OPTION_RESUME, show_message=TRUE)
if task['always_yes_mode'] != "true"
self.askUserForAction(task, action=DatasetUtils::OPTION_RESUME, show_message=TRUE)
else
self.alwaysYesDownload()
end
else
if @dataset_utils.discardChangesFileExist()
puts
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment