Skip to content

Commit 8ef1d28

Browse files
Merge pull request #54 from darknight1050/OculusDB-current
Null check for oldEntry
2 parents df65a6c + c7e611e commit 8ef1d28

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

OculusDB/ScrapingNodeCode/ScrapingNodeScraper.cs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -244,19 +244,19 @@ public void Scrape(AppToScrape app)
244244
foreach (OculusBinary b in versions.data.node.primary_binaries.nodes)
245245
{
246246
bool doPriorityForThisVersion = app.priority;
247-
DBVersion? oldEntry = connected.FirstOrDefault(x => x.id == b.id);
248-
TimeSpan timeDelta = DateTime.UtcNow - oldEntry.lastPriorityScrape;
249-
TimeSpan betweenScrapes = timeBetweenScrapes;
250-
// Make sure that the time between scrapes increases at a steady pace to not stress Oculus's servers too much
251-
if (timeDelta.TotalDays > 20)
252-
{
253-
betweenScrapes = timeDelta;
254-
if (betweenScrapes.TotalDays > 600) betweenScrapes = new TimeSpan(600, 0, 0, 0);
255-
}
256-
257-
if (doPriorityForThisVersion)
258-
{
259-
if (oldEntry != null)
247+
DBVersion? oldEntry = connected.FirstOrDefault(x => x.id == b.id);
248+
if (oldEntry != null)
249+
{
250+
TimeSpan timeDelta = DateTime.UtcNow - oldEntry.lastPriorityScrape;
251+
TimeSpan betweenScrapes = timeBetweenScrapes;
252+
// Make sure that the time between scrapes increases at a steady pace to not stress Oculus's servers too much
253+
if (timeDelta.TotalDays > 20)
254+
{
255+
betweenScrapes = timeDelta;
256+
if (betweenScrapes.TotalDays > 600) betweenScrapes = new TimeSpan(600, 0, 0, 0);
257+
}
258+
259+
if (doPriorityForThisVersion)
260260
{
261261
// Only do priority scrape if last scrape is older than 2 days
262262
if (timeDelta < betweenScrapes)
@@ -297,8 +297,8 @@ public void Scrape(AppToScrape app)
297297

298298
if (b != null && doPriorityForThisVersion)
299299
{
300-
Logger.Log("Scraping v " + b.version, LoggingType.Important);
301-
300+
Logger.Log("Scraping v " + b.version, LoggingType.Important);
301+
302302
}
303303
OculusBinary bin = b;
304304
bool wasNull = false;
@@ -311,7 +311,7 @@ public void Scrape(AppToScrape app)
311311
wasNull = true;
312312
bin = b;
313313
}
314-
if(bin.obb_binary == null && b.obb_binary != null) bin.obb_binary = b.obb_binary;
314+
if (bin.obb_binary == null && b.obb_binary != null) bin.obb_binary = b.obb_binary;
315315
}
316316
catch
317317
{
@@ -322,12 +322,12 @@ public void Scrape(AppToScrape app)
322322
Logger.Log("Got obb binary for " + b.id + " v " + b.version, LoggingType.Debug);
323323
b.obb_binary = info.data.node.obb_binary;
324324
}
325-
}
326-
327-
328-
// Preserve changelogs and obbs across scrapes by:
329-
// - Don't delete versions after scrape
330-
// - If not priority scrape enter changelog and obb of most recent versions
325+
}
326+
327+
328+
// Preserve changelogs and obbs across scrapes by:
329+
// - Don't delete versions after scrape
330+
// - If not priority scrape enter changelog and obb of most recent versions
331331
if ((!doPriorityForThisVersion || wasNull) && oldEntry != null)
332332
{
333333
bin.changeLog = oldEntry.changeLog;

0 commit comments

Comments
 (0)