Merge pull request #261 from wabbajack-tools/fix-missing-app-data-folder

Check if the directory exists first before saving data to it
This commit is contained in:
Timothy Baldridge 2019-12-12 12:17:32 -07:00 committed by GitHub
commit 45a08b4005
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -2,6 +2,8 @@
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;
using Alphaleonis.Win32.Filesystem;
using Syroot.Windows.IO;
namespace Wabbajack.Common
{
@ -84,6 +86,7 @@ namespace Wabbajack.Common
}
public static string HashFileExtension => ".xxHash";
public static string LocalAppDataPath => Path.Combine(KnownFolders.LocalAppData.Path, "Wabbajack");
public static string WabbajackCacheLocation = "http://build.wabbajack.org/nexus_api_cache/";
}

View File

@ -913,7 +913,11 @@ namespace Wabbajack.Common
{
var bytes = Encoding.UTF8.GetBytes(data.ToJSON());
var encoded = ProtectedData.Protect(bytes, Encoding.UTF8.GetBytes(key), DataProtectionScope.LocalMachine);
var path = Path.Combine(KnownFolders.LocalAppData.Path, "Wabbajack", key);
if (!Directory.Exists(Consts.LocalAppDataPath))
Directory.CreateDirectory(Consts.LocalAppDataPath);
var path = Path.Combine(Consts.LocalAppDataPath, key);
File.WriteAllBytes(path, encoded);
}