| 948 | |
| 949 | class Uploader |
| 950 | def upload |
| 951 | progress_label = "Uploading: #{target_base_path}" |
| 952 | progress_reporter = ProgressReporter.new(progress_label) |
| 953 | prefix = target_base_path |
| 954 | prefix += "/#{@destination_prefix}" if @destination_prefix |
| 955 | open_client_pool(prefix) do |client_pool| |
| 956 | if @sync |
| 957 | existing_files = client_pool.pull do |client| |
| 958 | client.files |
| 959 | end |
| 960 | else |
| 961 | existing_files = [] |
| 962 | end |
| 963 | |
| 964 | thread_pool = ThreadPool.new(thread_pool_use_case) do |path, relative_path| |
| 965 | client_pool.pull do |client| |
| 966 | client.upload(path, relative_path) |
| 967 | end |
| 968 | progress_reporter.advance |
| 969 | end |
| 970 | |
| 971 | source = Pathname(@source) |
| 972 | source.glob("**/*") do |path| |
| 973 | next if path.directory? |
| 974 | destination_path = path.relative_path_from(source) |
| 975 | progress_reporter.increment_max |
| 976 | existing_files.delete(destination_path.to_s) |
| 977 | thread_pool << [path, destination_path] |
| 978 | end |
| 979 | thread_pool.join |
| 980 | |
| 981 | if @sync |
| 982 | thread_pool = ThreadPool.new(thread_pool_use_case) do |path| |
| 983 | client_pool.pull do |client| |
| 984 | client.delete(path) |
| 985 | end |
| 986 | progress_reporter.advance |
| 987 | end |
| 988 | existing_files.each do |path| |
| 989 | if @sync_pattern |
| 990 | next unless @sync_pattern.match?(path) |
| 991 | end |
| 992 | progress_reporter.increment_max |
| 993 | thread_pool << path |
| 994 | end |
| 995 | thread_pool.join |
| 996 | end |
| 997 | end |
| 998 | progress_reporter.finish |
| 999 | end |
| 1000 | end |
| 1001 | |
| 1002 | class MavenRepositoryUploader < Uploader |
no test coverage detected