Skip to content

Commit 80b9406

Browse files
committed
Added options for re-generating item sets, loading them from file, etc.
1 parent 5406851 commit 80b9406

File tree

1 file changed

+37
-8
lines changed

1 file changed

+37
-8
lines changed

xivModdingFramework/Cache/XivCache.cs

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public static class XivCache
2828
private static DirectoryInfo _rootCachePath;
2929
public static readonly Version CacheVersion = new Version("0.0.1.1");
3030
private const string dbFileName = "mod_cache.db";
31-
private const string rootCacheFileName = "roots_cache.db";
31+
private const string rootCacheFileName = "item_sets.db";
3232
private const string creationScript = "CreateCacheDB.sql";
3333
private const string rootCacheCreationScript = "CreateRootCacheDB.sql";
3434
internal static string CacheConnectionString { get
@@ -313,15 +313,33 @@ private static void CreateCache()
313313

314314
if (!File.Exists(_rootCachePath.FullName))
315315
{
316-
using (var db = new SQLiteConnection(RootsCacheConnectionString))
317-
{
318-
db.Open();
319-
var lines = File.ReadAllLines("Resources\\SQL\\" + rootCacheCreationScript);
320-
var sqlCmd = String.Join("\n", lines);
316+
// If we don't have a root cache file, we can do a few things...
317+
var cwd = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
318+
var backupFile = cwd + "\\Resources\\DB\\" + rootCacheFileName;
321319

322-
using (var cmd = new SQLiteCommand(sqlCmd, db))
320+
if (File.Exists(backupFile))
321+
{
322+
// Copy the backup over. - Even if the backup is not for the correct patch of
323+
// FFXIV for this user's region, that's fine. It's still some reasonable data.
324+
// Worst case situation is either
325+
// A - They're missing some raw set listings in the menus (Not a big deal)
326+
// B - They have some raw set listings in the menus that they don't have yet. (Won't load, not a big deal.)
327+
File.Copy(backupFile, _rootCachePath.FullName);
328+
}
329+
else
330+
{
331+
// No backup DB to use, just create a blank schema, other functions will fallback to using the
332+
// roots from the item list as a partial list.
333+
using (var db = new SQLiteConnection(RootsCacheConnectionString))
323334
{
324-
cmd.ExecuteScalar();
335+
db.Open();
336+
var lines = File.ReadAllLines("Resources\\SQL\\" + rootCacheCreationScript);
337+
var sqlCmd = String.Join("\n", lines);
338+
339+
using (var cmd = new SQLiteCommand(sqlCmd, db))
340+
{
341+
cmd.ExecuteScalar();
342+
}
325343
}
326344
}
327345
}
@@ -1490,6 +1508,17 @@ public static async Task<List<XivDependencyRoot>> GetDependencyRoots(string inte
14901508
return roots;
14911509
}
14921510

1511+
/// <summary>
1512+
/// Re-scans the *ENTIRE* list of possible roots in the 040000 DAT file.
1513+
/// This operation takes a LONG time, and should not be done unless specifically
1514+
/// user initiated.
1515+
/// </summary>
1516+
/// <returns></returns>
1517+
public static async Task RebuildAllRoots()
1518+
{
1519+
await XivDependencyGraph.CacheAllRealRoots();
1520+
}
1521+
14931522

14941523
/// <summary>
14951524
/// Updates the file children in the dependencies cache.

0 commit comments

Comments
 (0)