@@ -41,30 +41,33 @@ protected List<Bookmark> GetBookmarksFromPath(string placesPath)
41
41
if ( string . IsNullOrEmpty ( placesPath ) || ! File . Exists ( placesPath ) )
42
42
return bookmarks ;
43
43
44
+ // Try to register file monitoring
45
+ try
46
+ {
47
+ Main . RegisterBookmarkFile ( placesPath ) ;
48
+ }
49
+ catch ( Exception ex )
50
+ {
51
+ Main . _context . API . LogException ( ClassName , $ "Failed to register Firefox bookmark file monitoring: { placesPath } ", ex ) ;
52
+ return bookmarks ;
53
+ }
54
+
44
55
var tempDbPath = Path . Combine ( _faviconCacheDir , $ "tempplaces_{ Guid . NewGuid ( ) } .sqlite") ;
45
56
46
57
try
47
58
{
48
- // Try to register file monitoring
49
- try
50
- {
51
- Main . RegisterBookmarkFile ( placesPath ) ;
52
- }
53
- catch ( Exception ex )
54
- {
55
- Main . _context . API . LogException ( ClassName , $ "Failed to register Firefox bookmark file monitoring: { placesPath } ", ex ) ;
56
- }
57
-
58
59
// Use a copy to avoid lock issues with the original file
59
60
File . Copy ( placesPath , tempDbPath , true ) ;
60
61
61
- // Connect to database and execute query
62
+ // Create the connection string and init the connection
62
63
string dbPath = string . Format ( DbPathFormat , tempDbPath ) ;
63
64
using var dbConnection = new SqliteConnection ( dbPath ) ;
65
+
66
+ // Open connection to the database file and execute the query
64
67
dbConnection . Open ( ) ;
65
68
var reader = new SqliteCommand ( QueryAllBookmarks , dbConnection ) . ExecuteReader ( ) ;
66
69
67
- // Create bookmark list
70
+ // Get results in List<Bookmark> format
68
71
bookmarks = reader
69
72
. Select (
70
73
x => new Bookmark (
@@ -75,12 +78,16 @@ protected List<Bookmark> GetBookmarksFromPath(string placesPath)
75
78
)
76
79
. ToList ( ) ;
77
80
78
- // Path to favicon database
79
- var faviconDbPath = Path . Combine ( Path . GetDirectoryName ( placesPath ) , "favicons.sqlite" ) ;
80
- if ( File . Exists ( faviconDbPath ) )
81
+ // Load favicons after loading bookmarks
82
+ if ( Main . _settings . EnableFavoriteIcons )
81
83
{
82
- LoadFaviconsFromDb ( faviconDbPath , bookmarks ) ;
84
+ var faviconDbPath = Path . Combine ( Path . GetDirectoryName ( placesPath ) , "favicons.sqlite" ) ;
85
+ if ( File . Exists ( faviconDbPath ) )
86
+ {
87
+ LoadFaviconsFromDb ( faviconDbPath , bookmarks ) ;
88
+ }
83
89
}
90
+
84
91
// https://github.com/dotnet/efcore/issues/26580
85
92
SqliteConnection . ClearPool ( dbConnection ) ;
86
93
dbConnection . Close ( ) ;
0 commit comments