1111require 'minitar'
1212
1313module MorphCLI
14- def self . execute ( directory , _development , env_config )
14+ def self . execute ( directory , _development , env_config , skip_data : false )
1515 all_paths = MorphCLI . all_paths ( directory )
1616
1717 unless all_paths . find { |file | /scraper\. [\S ]+$/ =~ file }
1818 warn "Can't find scraper to upload. Expected to find a file called scraper.rb, scraper.php, scraper.py, scraper.pl, scraper.js, etc to upload"
1919 exit ( 1 )
2020 end
2121
22+ database_path = MorphCLI . database_path ( directory )
23+ if skip_data
24+ all_paths . delete ( database_path )
25+ database_path = nil
26+ end
27+
2228 size = MorphCLI . get_dir_size ( directory , all_paths )
23- puts "Uploading #{ size } ..."
29+ puts "Uploading #{ size } #{ " (including #{ database_path } )" if database_path } ..."
2430
2531 file = MorphCLI . create_tar ( directory , all_paths )
2632
27- timeout = if env_config . key? ( :timeout )
28- env_config [ :timeout ]
29- else
30- 600 # 10 minutes should be "enough for everyone", right?
31- # Setting to nil will disable the timeout entirely.
32- # Default is 60 seconds.
33- end
34-
3533 connection = Faraday . new ( url : env_config [ :base_url ] ) do |f |
3634 f . request :multipart
3735 f . response :raise_error
@@ -44,7 +42,10 @@ def self.execute(directory, _development, env_config)
4442 api_key : env_config [ :api_key ] ,
4543 code : Faraday ::Multipart ::FilePart . new ( file , "application/octet-stream" )
4644 }
47- req . options . timeout = timeout
45+ # 10 minutes should be "enough for everyone", right?
46+ # Setting :timeout to nil in the config will disable the timeout
47+ # entirely. The Faraday default is 60 seconds.
48+ req . options . timeout = env_config . fetch ( :timeout , 600 )
4849 req . options . on_data = proc do |chunk , _overall_received_bytes , env |
4950 next unless env . status == 200
5051
0 commit comments