Skip to content

Commit

Permalink
Fix access control store deletes
Browse files Browse the repository at this point in the history
  • Loading branch information
webprofusion-chrisc committed Nov 8, 2024
1 parent 973d07a commit 3a02273
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
8 changes: 2 additions & 6 deletions src/Certify.Core/Management/CertifyManager/CertifyManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ private async Task InitDataStore()
// default sqlite storage
_itemManager = new SQLiteManagedItemStore("", _serviceLog);
_credentialsManager = new SQLiteCredentialStore("", _serviceLog);
_accessControl = new AccessControl(_serviceLog, new SQLiteAccessControlStore("", _serviceLog));
}
else
{
Expand Down Expand Up @@ -318,6 +319,7 @@ private async Task InitDataStore()
{
_itemManager = new SQLiteManagedItemStore("", _serviceLog);
_credentialsManager = new SQLiteCredentialStore("", _serviceLog);
_accessControl = new AccessControl(_serviceLog, new SQLiteAccessControlStore("",_serviceLog));
}

// attempt to create and delete a test item
Expand Down Expand Up @@ -517,12 +519,6 @@ public Task ApplyPreferences()
private IAccessControl _accessControl;
public Task<IAccessControl> GetCurrentAccessControl()
{
if (_accessControl == null)
{
var store = new SQLiteAccessControlStore();
_accessControl = new AccessControl(_serviceLog, store);
}

return Task.FromResult(_accessControl);
}
}
Expand Down
18 changes: 11 additions & 7 deletions src/Certify.Models/Util/EnvironmentUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private static void CreateAndApplyRestrictedACL(string path)
/// </summary>
/// <param name="subDirectory">optional subfolder to include</param>
/// <returns>full app data with with optional subdirectory</returns>
public static string CreateAppDataPath(string? subDirectory = null)
public static string CreateAppDataPath(string? subDirectory = null, bool skipCreation=false)
{
var parts = new List<string>()
{
Expand All @@ -99,16 +99,20 @@ public static string CreateAppDataPath(string? subDirectory = null)
}

var path = Path.Combine(parts.ToArray());
CreateAndApplyRestrictedACL(path);

if (subDirectory != null)
if (!skipCreation)
{
parts.Add(subDirectory);
path = Path.Combine(parts.ToArray());
CreateAndApplyRestrictedACL(path);

if (!Directory.Exists(path))
if (subDirectory != null)
{
Directory.CreateDirectory(path);
parts.Add(subDirectory);
path = Path.Combine(parts.ToArray());

if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
}
}

Expand Down

0 comments on commit 3a02273

Please sign in to comment.