Skip to content

Commit 764e1d0

Browse files
committed
Saving the DB download in the same directory as CompactGUI.exe was a bad idea. It now downloads to the temp directory, and then the DB is stored in My.Settings.
1 parent ad12699 commit 764e1d0

File tree

4 files changed

+46
-8
lines changed

4 files changed

+46
-8
lines changed

CompactGUI/App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@
3838
<setting name="SkipNonCompressable" serializeAs="String">
3939
<value>True</value>
4040
</setting>
41+
<setting name="ResultsDB" serializeAs="String">
42+
<value />
43+
</setting>
44+
<setting name="ResultsDB_Date" serializeAs="String">
45+
<value />
46+
</setting>
4147
</CompactGUI.My.MySettings>
4248
</userSettings>
4349
</configuration>

CompactGUI/My Project/Settings.Designer.vb

Lines changed: 24 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CompactGUI/My Project/Settings.settings

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,11 @@
2323
<Setting Name="SkipNonCompressable" Type="System.Boolean" Scope="User">
2424
<Value Profile="(Default)">True</Value>
2525
</Setting>
26+
<Setting Name="ResultsDB" Type="System.String" Scope="User">
27+
<Value Profile="(Default)" />
28+
</Setting>
29+
<Setting Name="ResultsDB_Date" Type="System.DateTime" Scope="User">
30+
<Value Profile="(Default)" />
31+
</Setting>
2632
</Settings>
2733
</SettingsFile>

CompactGUI/WikiHandler.vb

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,28 @@ Class WikiHandler
99
Shared InputFromGitHub As IEnumerable(Of XElement)
1010
Friend Shared allResults As New List(Of Result)
1111
Shared workingname As String = "testdir"
12-
Shared DBZipFileLoc As String = AppDomain.CurrentDomain.BaseDirectory & "\CompactGUI.zxm"
12+
Shared DBZipFileLoc As String = Path.GetTempPath & "CompactGUI.zxm"
1313

1414
Private Shared Sub WikiParser()
1515
Console.WriteLine("Working Name: " & workingname)
16-
16+
Console.WriteLine(DBZipFileLoc)
1717
allResults.Clear()
1818

19-
Console.WriteLine(New FileInfo(DBZipFileLoc).LastWriteTime)
20-
If InputFromGitHub Is Nothing AndAlso File.Exists(DBZipFileLoc) AndAlso Date.Now < (New FileInfo(DBZipFileLoc).LastWriteTime.AddHours(24)) Then
19+
Console.WriteLine(My.Settings.ResultsDB_Date)
20+
If InputFromGitHub Is Nothing AndAlso My.Settings.ResultsDB IsNot Nothing AndAlso Date.Now < My.Settings.ResultsDB_Date.AddHours(12) Then
2121
Console.WriteLine("Using existing DB")
2222
InitialiseInputFromGithub()
2323

2424
ElseIf InputFromGitHub Is Nothing Then
2525
Console.WriteLine("Fetching New DB")
26+
2627
Dim wc = New WebClient With {.Encoding = Encoding.UTF8}
2728
Try
2829
wc.DownloadFile("https://raw.githubusercontent.com/ImminentFate/CompactGUI/master/Wiki/Database.zip", DBZipFileLoc)
30+
Dim x As Compression.ZipArchive = Compression.ZipFile.OpenRead(DBZipFileLoc)
31+
Dim stre As StreamReader = New StreamReader(x.Entries(0).Open())
32+
My.Settings.ResultsDB = stre.ReadToEnd
33+
My.Settings.ResultsDB_Date = Date.Now
2934
InitialiseInputFromGithub()
3035

3136
Catch ex As WebException
@@ -47,9 +52,7 @@ Class WikiHandler
4752

4853
Private Shared Sub InitialiseInputFromGithub()
4954
Dim SRC As XElement
50-
Dim x As Compression.ZipArchive = Compression.ZipFile.OpenRead(DBZipFileLoc)
51-
Dim stre As StreamReader = New StreamReader(x.Entries(0).Open())
52-
SRC = XElement.Parse(stre.ReadToEnd)
55+
SRC = XElement.Parse(My.Settings.ResultsDB)
5356
InputFromGitHub = SRC.Elements()
5457
ParseData()
5558
End Sub

0 commit comments

Comments
 (0)