Commit 04090942 authored by Roque's avatar Roque

always yes mode for uploads and downloads

parent 9de1e703
...@@ -60,11 +60,15 @@ module Embulk ...@@ -60,11 +60,15 @@ module Embulk
if not conflicts.empty? if not conflicts.empty?
puts puts
@logger.warn("Some of your local files already exist in remote dataset.", print=TRUE) @logger.warn("Some of your local files already exist in remote dataset.", 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) @logger.warn("You may want to cancel this partial ingestion and download the full dataset to make local changes.", print=TRUE)
end
puts puts
@logger.warn("Current ingestion WILL OVERWRITE the following files in remote dataset:", print=TRUE) @logger.warn("Current ingestion WILL OVERWRITE the following files in remote dataset:", print=TRUE)
if task['always_yes_mode'] != "true"
puts "** press key **" puts "** press key **"
option = gets option = gets
end
print_short = conflicts.length > 500 print_short = conflicts.length > 500
@dataset_utils.showChangesList(conflicts, "", print_short, status=DatasetUtils::OVERWRITE) @dataset_utils.showChangesList(conflicts, "", print_short, status=DatasetUtils::OVERWRITE)
else else
...@@ -85,6 +89,7 @@ module Embulk ...@@ -85,6 +89,7 @@ module Embulk
if task['chunk_size'] == 0 if task['chunk_size'] == 0
task['chunk_size'] = DatasetUtils::CHUNK_SIZE task['chunk_size'] = DatasetUtils::CHUNK_SIZE
end end
task['always_yes_mode'] = config.param('always_yes', :string)
@data_set = task['data_set'] @data_set = task['data_set']
@dataset_utils = DatasetUtils.new("") @dataset_utils = DatasetUtils.new("")
paths = config.param('path_prefix', :array) paths = config.param('path_prefix', :array)
...@@ -133,7 +138,7 @@ module Embulk ...@@ -133,7 +138,7 @@ module Embulk
else else
if not @dataset_utils.partialIngestionFileExist() if not @dataset_utils.partialIngestionFileExist()
@logger.info("Checking local dataset...", print=TRUE) @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 puts
@logger.error("Your current dataset is outdated. Please, run a download to update it before ingest your changes.", print=TRUE) @logger.error("Your current dataset is outdated. Please, run a download to update it before ingest your changes.", print=TRUE)
puts puts
...@@ -153,6 +158,7 @@ module Embulk ...@@ -153,6 +158,7 @@ module Embulk
end end
self.status(task, push=TRUE) self.status(task, push=TRUE)
if task['always_yes_mode'] != "true"
@logger.info("Continue with ingestion? (y/n)", print=TRUE) @logger.info("Continue with ingestion? (y/n)", print=TRUE)
option = gets option = gets
option = option.chomp option = option.chomp
...@@ -160,6 +166,7 @@ module Embulk ...@@ -160,6 +166,7 @@ module Embulk
@logger.info("Ingestion cancelled by user.", print=TRUE) @logger.info("Ingestion cancelled by user.", print=TRUE)
@logger.abortExecution() @logger.abortExecution()
end end
end
if not @dataset_utils.reportFileExist() if not @dataset_utils.reportFileExist()
@dataset_utils.createReportFile() @dataset_utils.createReportFile()
end end
......
...@@ -31,6 +31,14 @@ module Embulk ...@@ -31,6 +31,14 @@ module Embulk
end end
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) def self.askUserForAction(task, action, show_message)
option = @dataset_utils.getConfiguration(action, task['tool_dir']) option = @dataset_utils.getConfiguration(action, task['tool_dir'])
valid_option = option != DatasetUtils::OPTION_ABORT ? TRUE : FALSE valid_option = option != DatasetUtils::OPTION_ABORT ? TRUE : FALSE
...@@ -104,7 +112,8 @@ module Embulk ...@@ -104,7 +112,8 @@ module Embulk
'data_set' => @data_set, 'data_set' => @data_set,
'chunk_size' => DatasetUtils::CHUNK_SIZE + 10, 'chunk_size' => DatasetUtils::CHUNK_SIZE + 10,
'output_path' => @output_path, '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 if task['chunk_size'] == 0
task['chunk_size'] = DatasetUtils::CHUNK_SIZE task['chunk_size'] = DatasetUtils::CHUNK_SIZE
...@@ -158,10 +167,18 @@ module Embulk ...@@ -158,10 +167,18 @@ module Embulk
task['data_streams'] = @dataset_utils.getRemoteFileListForDiscardLocalChanges(task['data_streams'], @data_set, task['data_streams'] = @dataset_utils.getRemoteFileListForDiscardLocalChanges(task['data_streams'], @data_set,
check_changes=FALSE, changes=local_changes) check_changes=FALSE, changes=local_changes)
else else
if task['always_yes_mode'] != "true"
self.askUserForAction(task, action=DatasetUtils::OPTION_UPDATE, show_message=TRUE) self.askUserForAction(task, action=DatasetUtils::OPTION_UPDATE, show_message=TRUE)
else
self.alwaysYesDownload()
end
end end
elsif not @dataset_utils.partialIngestionFileExist() elsif not @dataset_utils.partialIngestionFileExist()
if task['always_yes_mode'] != "true"
self.askUserForAction(task, action=DatasetUtils::OPTION_RESUME, show_message=TRUE) self.askUserForAction(task, action=DatasetUtils::OPTION_RESUME, show_message=TRUE)
else
self.alwaysYesDownload()
end
else else
if @dataset_utils.discardChangesFileExist() if @dataset_utils.discardChangesFileExist()
puts 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