Make sure the places.sqlite file exists

before loading Firefox bookmarks.
This commit is contained in:
Ioannis G
2014-07-02 18:43:54 +03:00
parent 6807dcbd5d
commit 73530f59de
3 changed files with 10 additions and 0 deletions

View File

@@ -22,6 +22,7 @@ namespace Wox.Plugin.BrowserBookmark
public List<Bookmark> GetBookmarks(string search = null)
{
//TODO: Maybe load bookmarks here instead of pre-loading them at startup?
if (string.IsNullOrEmpty(search)) return bookmarks;
var fuzzyMatcher = FuzzyMatcher.Create(search);

View File

@@ -42,6 +42,10 @@ namespace Wox.Plugin.BrowserBookmark
/// </summary>
private List<Bookmark> GetResults(string query)
{
// Return empty list if the places.sqlite file cannot be found
if (string.IsNullOrEmpty(PlacesPath) || !File.Exists(PlacesPath))
return new List<Bookmark>();
// create the connection string and init the connection
string dbPath = string.Format(dbPathFormat, PlacesPath);
var dbConnection = new SQLiteConnection(dbPath);
@@ -66,6 +70,10 @@ namespace Wox.Plugin.BrowserBookmark
get
{
var profilesPath = Environment.ExpandEnvironmentVariables(@"%appdata%\Mozilla\Firefox\Profiles\");
// return null if the Profiles folder does not exist
if (!Directory.Exists(profilesPath)) return null;
var folders = new DirectoryInfo(profilesPath).GetDirectories().Select(x => x.FullName).ToList();
// Look for the default profile folder

View File

@@ -25,6 +25,7 @@ namespace Wox.Plugin.BrowserBookmark
var returnList = new List<Bookmark>();
//TODO: Let the user select which browser's bookmarks are displayed
// Add Firefox bookmarks
returnList.AddRange(mozBookmarks.GetBookmarks(param, topResults));
// Add Chrome bookmarks