Skip to content

Commit d42d35e

Browse files
authored
Merge pull request #101 from Flow-Launcher/dev
Release 1.1.0 | Plugin 1.1.0 | Explorer Plugin 1.1.0
2 parents 7c35c3e + 956ab1f commit d42d35e

File tree

52 files changed

+750
-594
lines changed

Some content is hidden

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

52 files changed

+750
-594
lines changed

.github/ISSUE_TEMPLATE/bug-report.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
name: "\U0001F41E Bug report"
3+
about: Create a bug report to help us improve Flow Launcher
4+
title: "[Describe Your Bug]"
5+
labels: 'bug'
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug/issue**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
1. ...
16+
2. ...
17+
3. ...
18+
19+
**Screenshots**
20+
If applicable, add screenshots to help explain your problem.
21+
22+
**Your System**
23+
```
24+
Windows build number: (run "ver" at a command prompt)
25+
Flow Launcher version: (Settings => About)
26+
```
27+
**Flow Launcher Error Log**
28+
<!--
29+
The latest log file can be found here: %AppData%\FlowLauncher\Logs\<version>\<date>.txt
30+
or for portable mode: %LocalAppData%\FlowLauncher\<App-Version>\UserData\Logs\<version>\<date>.txt
31+
Drag and drop the log file below this comment.
32+
-->

.github/ISSUE_TEMPLATE/code-review.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
name: "\U0001F50E Code Review"
3+
about: Describe (bad) code that needs to be improved
4+
title: "[Describe Problematic Code]"
5+
labels: 'code review'
6+
assignees: ''
7+
8+
---
9+
10+
**Point to the corresponding file and line number(s) which could be improved.**
11+
12+
Click on the line number in GitHub to create an anchored link to the corresponding code section. For example:
13+
14+
15+
https://github.com/Flow-Launcher/Flow.Launcher/blob/master/Flow.Launcher/Storage/TopMostRecord.cs#L8
16+
17+
Provide your alternative implementation idea:
18+
19+
```
20+
Code
21+
```

.github/ISSUE_TEMPLATE/discussion.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
name: "⁉️ Question/Discussion"
3+
about: Create a report to help us improve
4+
title: "[Ask a question or propose a change]"
5+
labels: 'question/discussion'
6+
assignees: ''
7+
8+
---
9+
10+
**Question**
11+
Describe your question.
12+
13+
**Discussion**
14+
Discuss a topic.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
name: "⭐ Feature request"
3+
about: Suggest a new idea or a feature enhacement
4+
title: "[Describe Your Feature]"
5+
labels: 'enhancement'
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
12+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
13+
14+
**Describe the solution you'd like**
15+
16+
A clear and concise description of what you want to happen.
17+
18+
**Describe alternatives you've considered**
19+
20+
A clear and concise description of any alternative solutions or features you've considered.
21+
22+
**Additional context**
23+
24+
Add any other context or screenshots about the feature request here.

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)