Skip to content

Commit

Permalink
fix(core): creates Speckle folders if they do not exist (#1953)
Browse files Browse the repository at this point in the history
* wip: tryes handling issues with sql and accounts

* fix(core): use Environment.SpecialFolderOption.Createoption for Core folders
  • Loading branch information
teocomi authored Nov 30, 2022
1 parent c8641e4 commit f48458c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Core/Core/Api/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public static string PluralS(int num)
public static string InstallApplicationDataPath =>

Assembly.GetAssembly(typeof(Helpers)).Location.Contains("ProgramData")
? Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)
? Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData, Environment.SpecialFolderOption.Create)
: UserApplicationDataPath;


Expand All @@ -278,7 +278,7 @@ public static string PluralS(int num)
public static string UserApplicationDataPath =>
!string.IsNullOrEmpty(Environment.GetEnvironmentVariable(_speckleUserDataEnvVar)) ?
Environment.GetEnvironmentVariable(_speckleUserDataEnvVar) :
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData, Environment.SpecialFolderOption.Create);



Expand Down
15 changes: 12 additions & 3 deletions Core/Core/Transports/SQLite.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using System;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using Microsoft.Data.Sqlite;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using System.Timers;
using Microsoft.Data.Sqlite;
using Microsoft.Data.Sqlite;
using Speckle.Core.Api;

namespace Speckle.Core.Transports
Expand Down Expand Up @@ -58,7 +58,16 @@ public SQLiteTransport(string basePath = null, string applicationName = "Speckle
scope = "Data";
_Scope = scope;

Directory.CreateDirectory(Path.Combine(basePath, applicationName)); //ensure dir is there
var dir = Path.Combine(basePath, applicationName);
try
{
Directory.CreateDirectory(dir); //ensure dir is there
}
catch (Exception ex)
{
throw new Exception($"Cound not create {dir}", ex);
}


RootPath = Path.Combine(basePath, applicationName, $"{scope}.db");
//fix for network drives: https://stackoverflow.com/a/18506097/826060
Expand Down

0 comments on commit f48458c

Please sign in to comment.