gh-archive 0.9 → 0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/gh-archive.rb +29 -27
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 498649edc20ceb260d6468cd7e9ff46781e148205c17cc2c6dd65cd8c7258e8f
4
- data.tar.gz: 6e14d05254a7dcddc3a5afdf1c5e749602fdffc508df70dd1a01ebc97642a78c
3
+ metadata.gz: b1a8f0a5088aa3d598466d5ef3ba3472b5e9b0c2ad3327f291c24045c01bdfba
4
+ data.tar.gz: b3df61810f7634eb8e9a153a812fa2073078975ee0ca303bfb9fb87e58f08160
5
5
  SHA512:
6
- metadata.gz: 6b3156cdeec56577f61961b53c5552670534aaba0de3391daba5a99afc23fd09deb79da47879e2fc326eae4e85bbb180c41ca170540f67aa428c73571e443fad
7
- data.tar.gz: 8129e09a30fd7abe02066ff890dcbd4d48f6965156f92d92582880883a11e508f397358aa39265fc65e7152c2e8204623a417c8689d3096c34e70df411e092f2
6
+ metadata.gz: f5462029f6ef8e32f632bfdb7552606cf47a924e019502288ee2d841e28e76a5899d944d912a41933834e08e7a813c88cc919a7e93dba42b1c3250fcd911ae6e
7
+ data.tar.gz: 1f180c6640e38423ac2cde87ee4181cf04db8bb0a5cc6f861fd39d5de0c5bc4d30df87524f594482c170d591c5cd063abfa539b5715a4850056ab5262acef965
data/lib/gh-archive.rb CHANGED
@@ -101,9 +101,7 @@ class GHAProvider
101
101
  return self
102
102
  end
103
103
 
104
- def each(from = Time.gm(2015, 1, 1), to = Time.now)
105
- exceptions = []
106
-
104
+ def restore_checkpoint(from)
107
105
  if @checkpoint_name && FileTest.exist?(@checkpoint_name)
108
106
  # Note that this throws an exception if the file is not readable. This is the intended behavior.
109
107
  # As opposed to that, failing to save the checkpoint information just results in a warning on the log.
@@ -111,8 +109,31 @@ class GHAProvider
111
109
  raise "The loaded checkpoint (#{loaded_from}) occurs before the current from date (#{from})" if loaded_from < from
112
110
 
113
111
  @logger.info("Valid checkpoint loaded. Restored execution from #{loaded_from}.")
114
- from = loaded_from
112
+
113
+ return loaded_from
114
+ else
115
+ return from
116
+ end
117
+ end
118
+
119
+ def update_checkpoint(current_time)
120
+ if @checkpoint_name
121
+ begin
122
+ File.open(@checkpoint_name, "wb") do |f|
123
+ f.write(Marshal.dump(current_time))
124
+ end
125
+ rescue
126
+ @logger.warn(
127
+ "Unable to save the checkpoint at the specified location (#{File.expand_path(@checkpoint_name)})."
128
+ )
129
+ end
115
130
  end
131
+ end
132
+
133
+ def each(from = Time.gm(2015, 1, 1), to = Time.now)
134
+ exceptions = []
135
+
136
+ from = restore_checkpoint(from)
116
137
 
117
138
  self.each_time(from, to) do |current_time|
118
139
  events = []
@@ -127,17 +148,7 @@ class GHAProvider
127
148
  next
128
149
  end
129
150
 
130
- if @checkpoint_name
131
- begin
132
- File.open(@checkpoint_name, "wb") do |f|
133
- f.write(Marshal.dump(current_time))
134
- end
135
- rescue
136
- @logger.warn(
137
- "Unable to save the checkpoint at the specified location (#{File.expand_path(@checkpoint_name)})."
138
- )
139
- end
140
- end
151
+ update_checkpoint(current_time)
141
152
 
142
153
  events.each do |event|
143
154
  skip = false
@@ -163,17 +174,7 @@ class GHAProvider
163
174
  GC.start
164
175
  end
165
176
 
166
- if @checkpoint_name
167
- begin
168
- File.open(@checkpoint_name, "wb") do |f|
169
- f.write(Marshal.dump(to))
170
- end
171
- rescue
172
- @logger.warn(
173
- "Unable to save the checkpoint at the specified location (#{File.expand_path(@checkpoint_name)})."
174
- )
175
- end
176
- end
177
+ update_checkpoint(to)
177
178
 
178
179
  return exceptions
179
180
  end
@@ -258,10 +259,11 @@ class OnlineGHAProvider < GHAProvider
258
259
 
259
260
  def each(from = Time.gm(2015, 1, 1), to = Time.now)
260
261
  if @proactive
262
+ real_from = restore_checkpoint(from)
261
263
  any_ready = Thread.promise
262
264
 
263
265
  @logger.info("Proactively scheduling download tasks...")
264
- self.each_time(from, to) do |current_time|
266
+ self.each_time(real_from, to) do |current_time|
265
267
  @pool.process(current_time) do |current_time|
266
268
  cache(current_time)
267
269
  any_ready << true
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gh-archive
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.9'
4
+ version: '0.10'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simone Scalabrino
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-14 00:00:00.000000000 Z
11
+ date: 2021-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: code-assertions