File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ gemfile do
1010 gem "logger"
1111 gem "base64"
1212 gem "activesupport" , require : "active_support/all"
13+ gem "parallel"
1314end
1415
1516continuation_token_file = File . join ( __dir__ , ".initiate-backfill.continuation_token" )
@@ -26,14 +27,16 @@ stats = Hash.new do |h, k|
2627 y , m = k
2728 h [ k ] = Stats . new ( y , m , 0 , 0 )
2829end
29-
30+ MUTEX = Mutex . new
3031increment = lambda do |object |
3132 k = object . key . match ( /fastly_json\/ (\d {4}).(\d {2})/ ) &.captures || (
3233 puts "\n Ignoring #{ object . key . inspect } " ;
3334 return
3435 )
35- puts stats . values . last unless stats . key? ( k )
36- stats [ k ] . increment ( object )
36+ MUTEX . synchronize do
37+ puts stats . values . last unless stats . key? ( k )
38+ stats [ k ] . increment ( object )
39+ end
3740end
3841
3942client = Aws ::S3 ::Client . new
4548 continuation_token :,
4649 )
4750
48- response . contents . each do |object |
51+ Parallel . each ( response . contents , in_threads : 10 ) do |object |
4952 increment . call ( object )
5053 client . restore_object (
5154 bucket :,
You can’t perform that action at this time.
0 commit comments