diff --git a/Flow.Launcher.Core/Configuration/Portable.cs b/Flow.Launcher.Core/Configuration/Portable.cs index 21bd04bda..fae78b705 100644 --- a/Flow.Launcher.Core/Configuration/Portable.cs +++ b/Flow.Launcher.Core/Configuration/Portable.cs @@ -74,16 +74,6 @@ namespace Flow.Launcher.Core.Configuration /// public void PreStartCleanUpAfterPortabilityUpdate() { - // check whether the package locate in %LocalAppData% - // if not create the portable data folder - // Don't create the folder if the version is 1.0.0 (Dev) to allow potential debugging with data in the project folder - // It is still possible to create the UserData folder for dev version manually but we want to keep the current behavior - if (!Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData).PathContains(Constant.ProgramDirectory) - && Constant.Version != "1.0.0") - { - Directory.CreateDirectory(DataLocation.PortableDataPath); - } - // Specify here so this method does not rely on other environment variables to initialise var portableDataDir = DataLocation.PortableDataPath; var roamingDataDir = DataLocation.RoamingDataPath; diff --git a/Flow.Launcher.Infrastructure/UserSettings/DataLocation.cs b/Flow.Launcher.Infrastructure/UserSettings/DataLocation.cs index e294f52b8..51ff5157d 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/DataLocation.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/DataLocation.cs @@ -1,14 +1,32 @@ using System; using System.IO; +using Flow.Launcher.Plugin.SharedCommands; namespace Flow.Launcher.Infrastructure.UserSettings { public static class DataLocation { + static DataLocation() + { + // check whether the package locate in %LocalAppData% + // if not create the portable data folder + // Don't create the folder if the version is 1.0.0 (Dev) to allow potential debugging with data in the project folder + // It is still possible to create the UserData folder for dev version manually but we want to keep the current behavior + if (!Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + .PathContains(Constant.ProgramDirectory) + && Constant.Version != "1.0.0") + { + Directory.CreateDirectory(PortableDataPath); + } + } + public const string PortableFolderName = "UserData"; public const string DeletionIndicatorFile = ".dead"; public static string PortableDataPath = Path.Combine(Constant.ProgramDirectory, PortableFolderName); - public static string RoamingDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "FlowLauncher"); + + public static string RoamingDataPath = + Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "FlowLauncher"); + public static string DataDirectory() { if (PortableDataLocationInUse()) @@ -26,7 +44,9 @@ namespace Flow.Launcher.Infrastructure.UserSettings } public static readonly string PluginsDirectory = Path.Combine(DataDirectory(), Constant.Plugins); - public static readonly string PluginSettingsDirectory = Path.Combine(DataDirectory(), "Settings", Constant.Plugins); + + public static readonly string PluginSettingsDirectory = + Path.Combine(DataDirectory(), "Settings", Constant.Plugins); public const string PythonEnvironmentName = "Python"; public const string NodeEnvironmentName = "Node.js";