Skip to content

Commit 2ff4ffd

Browse files
committed
Merge remote-tracking branch 'origin/dev' into fix_stringmatcher_resultweighting
2 parents 9d45158 + 4c20dbc commit 2ff4ffd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+2555
-367
lines changed

Doc/Logo/app_error.png

14.6 KB
Loading

Doc/Logo/logo.ico

114 KB
Binary file not shown.

Doc/Logo/logo.png

49.6 KB
Loading

Doc/Logo/logo.svg

Lines changed: 1 addition & 0 deletions
Loading

Doc/Logo/logo128.png

2.44 KB
Loading

Doc/Logo/logo16.png

409 Bytes
Loading

Doc/Logo/logo256.png

5.57 KB
Loading

Doc/Logo/logo32.png

663 Bytes
Loading

Doc/Logo/logo48.png

1019 Bytes
Loading

Doc/Logo/logo512.png

13.5 KB
Loading

Doc/Logo/logo64.png

1.24 KB
Loading
Loading
16.6 KB
Loading
Loading
19.2 KB
Loading

Doc/Logo/resources/flow-logo.ai

Lines changed: 2249 additions & 0 deletions
Large diffs are not rendered by default.

Doc/Logo/resources/preview.pdf

408 KB
Binary file not shown.

Doc/app.ico

113 KB
Binary file not shown.

Doc/app.png

229 Bytes
Loading

Doc/app_error.png

13.6 KB
Loading

Flow.Launcher.Core/Configuration/Portable.cs

Lines changed: 28 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,9 @@ public void DisablePortableMode()
3232
try
3333
{
3434
MoveUserDataFolder(DataLocation.PortableDataPath, DataLocation.RoamingDataPath);
35-
#if DEBUG
35+
#if !DEBUG
3636
// Create shortcuts and uninstaller are not required in debug mode,
3737
// otherwise will repoint the path of the actual installed production version to the debug version
38-
#else
3938
CreateShortcuts();
4039
CreateUninstallerEntry();
4140
#endif
@@ -48,10 +47,7 @@ public void DisablePortableMode()
4847
}
4948
catch (Exception e)
5049
{
51-
#if !DEBUG
52-
Log.Exception("Portable", "Error occured while disabling portable mode", e);
53-
#endif
54-
throw;
50+
Log.Exception("|Portable.DisablePortableMode|Error occured while disabling portable mode", e);
5551
}
5652
}
5753

@@ -60,10 +56,9 @@ public void EnablePortableMode()
6056
try
6157
{
6258
MoveUserDataFolder(DataLocation.RoamingDataPath, DataLocation.PortableDataPath);
63-
#if DEBUG
59+
#if !DEBUG
6460
// Remove shortcuts and uninstaller are not required in debug mode,
6561
// otherwise will delete the actual installed production version
66-
#else
6762
RemoveShortcuts();
6863
RemoveUninstallerEntry();
6964
#endif
@@ -76,10 +71,7 @@ public void EnablePortableMode()
7671
}
7772
catch (Exception e)
7873
{
79-
#if !DEBUG
80-
Log.Exception("Portable", "Error occured while enabling portable mode", e);
81-
#endif
82-
throw;
74+
Log.Exception("|Portable.EnablePortableMode|Error occured while enabling portable mode", e);
8375
}
8476
}
8577

@@ -125,14 +117,13 @@ public void CreateShortcuts()
125117
public void CreateUninstallerEntry()
126118
{
127119
var uninstallRegSubKey = @"Software\Microsoft\Windows\CurrentVersion\Uninstall";
128-
// NB: Sometimes the Uninstall key doesn't exist
129-
using (var parentKey =
130-
RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Default)
131-
.CreateSubKey("Uninstall", RegistryKeyPermissionCheck.ReadWriteSubTree)) {; }
132120

133-
var key = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Default)
134-
.CreateSubKey(uninstallRegSubKey + "\\" + Constant.FlowLauncher, RegistryKeyPermissionCheck.ReadWriteSubTree);
135-
key.SetValue("DisplayIcon", Constant.ApplicationDirectory + "\\app.ico", RegistryValueKind.String);
121+
using (var baseKey = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Default))
122+
using (var subKey1 = baseKey.CreateSubKey(uninstallRegSubKey, RegistryKeyPermissionCheck.ReadWriteSubTree))
123+
using (var subKey2 = subKey1.CreateSubKey(Constant.FlowLauncher, RegistryKeyPermissionCheck.ReadWriteSubTree))
124+
{
125+
subKey2.SetValue("DisplayIcon", Path.Combine(Constant.ApplicationDirectory, "app.ico"), RegistryValueKind.String);
126+
}
136127

137128
using (var portabilityUpdater = NewUpdateManager())
138129
{
@@ -142,7 +133,10 @@ public void CreateUninstallerEntry()
142133

143134
internal void IndicateDeletion(string filePathTodelete)
144135
{
145-
using (StreamWriter sw = File.CreateText(filePathTodelete + "\\" + DataLocation.DeletionIndicatorFile)){}
136+
var deleteFilePath = Path.Combine(filePathTodelete, DataLocation.DeletionIndicatorFile);
137+
using (var _ = File.CreateText(deleteFilePath))
138+
{
139+
}
146140
}
147141

148142
///<summary>
@@ -152,21 +146,18 @@ internal void IndicateDeletion(string filePathTodelete)
152146
public void PreStartCleanUpAfterPortabilityUpdate()
153147
{
154148
// Specify here so this method does not rely on other environment variables to initialise
155-
var portableDataPath = Path.Combine(Directory.GetParent(Assembly.GetExecutingAssembly().Location.NonNull()).ToString(), "UserData");
156-
var roamingDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "FlowLauncher");
157-
158-
bool DataLocationPortableDeleteRequired = false;
159-
bool DataLocationRoamingDeleteRequired = false;
160-
161-
if ((roamingDataPath + "\\" + DataLocation.DeletionIndicatorFile).FileExits())
162-
DataLocationRoamingDeleteRequired = true;
149+
var portableDataDir = Path.Combine(Directory.GetParent(Assembly.GetExecutingAssembly().Location.NonNull()).ToString(), "UserData");
150+
var roamingDataDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "FlowLauncher");
163151

164-
if ((portableDataPath + "\\" + DataLocation.DeletionIndicatorFile).FileExits())
165-
DataLocationPortableDeleteRequired = true;
152+
// Get full path to the .dead files for each case
153+
var portableDataDeleteFilePath = Path.Combine(portableDataDir, DataLocation.DeletionIndicatorFile);
154+
var roamingDataDeleteFilePath = Path.Combine(roamingDataDir, DataLocation.DeletionIndicatorFile);
166155

167-
if (DataLocationRoamingDeleteRequired)
156+
// If the data folder in %appdata% is marked for deletion,
157+
// delete it and prompt the user to pick the portable data location
158+
if (File.Exists(roamingDataDeleteFilePath))
168159
{
169-
FilesFolders.RemoveFolderIfExists(roamingDataPath);
160+
FilesFolders.RemoveFolderIfExists(roamingDataDir);
170161

171162
if (MessageBox.Show("Flow Launcher has detected you enabled portable mode, " +
172163
"would you like to move it to a different location?", string.Empty,
@@ -176,18 +167,15 @@ public void PreStartCleanUpAfterPortabilityUpdate()
176167

177168
Environment.Exit(0);
178169
}
179-
180-
return;
181170
}
182-
183-
if(DataLocationPortableDeleteRequired)
171+
// Otherwise, if the portable data folder is marked for deletion,
172+
// delete it and notify the user about it.
173+
else if (File.Exists(portableDataDeleteFilePath))
184174
{
185-
FilesFolders.RemoveFolderIfExists(portableDataPath);
175+
FilesFolders.RemoveFolderIfExists(portableDataDir);
186176

187177
MessageBox.Show("Flow Launcher has detected you disabled portable mode, " +
188178
"the relevant shortcuts and uninstaller entry have been created");
189-
190-
return;
191179
}
192180
}
193181

@@ -196,7 +184,7 @@ public bool CanUpdatePortability()
196184
var roamingLocationExists = DataLocation.RoamingDataPath.LocationExists();
197185
var portableLocationExists = DataLocation.PortableDataPath.LocationExists();
198186

199-
if(roamingLocationExists && portableLocationExists)
187+
if (roamingLocationExists && portableLocationExists)
200188
{
201189
MessageBox.Show(string.Format("Flow Launcher detected your user data exists both in {0} and " +
202190
"{1}. {2}{2}Please delete {1} in order to proceed. No changes have occured.",

Flow.Launcher.Core/Plugin/PluginConfig.cs

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.IO;
5-
using System.Threading.Tasks;
65
using Newtonsoft.Json;
7-
using Flow.Launcher.Infrastructure.Exception;
6+
using Flow.Launcher.Infrastructure;
87
using Flow.Launcher.Infrastructure.Logger;
98
using Flow.Launcher.Plugin;
109

@@ -13,24 +12,16 @@ namespace Flow.Launcher.Core.Plugin
1312

1413
internal abstract class PluginConfig
1514
{
16-
private const string PluginConfigName = "plugin.json";
17-
private static readonly List<PluginMetadata> PluginMetadatas = new List<PluginMetadata>();
18-
1915
/// <summary>
20-
/// Parse plugin metadata in giving directories
16+
/// Parse plugin metadata in the given directories
2117
/// </summary>
2218
/// <param name="pluginDirectories"></param>
2319
/// <returns></returns>
2420
public static List<PluginMetadata> Parse(string[] pluginDirectories)
2521
{
26-
PluginMetadatas.Clear();
22+
var allPluginMetadata = new List<PluginMetadata>();
2723
var directories = pluginDirectories.SelectMany(Directory.GetDirectories);
28-
ParsePluginConfigs(directories);
29-
return PluginMetadatas;
30-
}
3124

32-
private static void ParsePluginConfigs(IEnumerable<string> directories)
33-
{
3425
// todo use linq when diable plugin is implmented since parallel.foreach + list is not thread saft
3526
foreach (var directory in directories)
3627
{
@@ -50,15 +41,17 @@ private static void ParsePluginConfigs(IEnumerable<string> directories)
5041
PluginMetadata metadata = GetPluginMetadata(directory);
5142
if (metadata != null)
5243
{
53-
PluginMetadatas.Add(metadata);
44+
allPluginMetadata.Add(metadata);
5445
}
5546
}
5647
}
48+
49+
return allPluginMetadata;
5750
}
5851

5952
private static PluginMetadata GetPluginMetadata(string pluginDirectory)
6053
{
61-
string configPath = Path.Combine(pluginDirectory, PluginConfigName);
54+
string configPath = Path.Combine(pluginDirectory, Constant.PluginMetadataFileName);
6255
if (!File.Exists(configPath))
6356
{
6457
Log.Error($"|PluginConfig.GetPluginMetadata|Didn't find config file <{configPath}>");
@@ -81,7 +74,6 @@ private static PluginMetadata GetPluginMetadata(string pluginDirectory)
8174
return null;
8275
}
8376

84-
8577
if (!AllowedLanguage.IsAllowed(metadata.Language))
8678
{
8779
Log.Error($"|PluginConfig.GetPluginMetadata|Invalid language <{metadata.Language}> for config <{configPath}>");

0 commit comments

Comments
 (0)