avoid exception in ChromiumBookmarkLoader.cs

Every time I start Flow Launcher since the plugins refactor, the Bookmarks plugin has been throwing an exception.  The issue stems from it parsing the Bookmarks file, and assuming that every JsonElement in the "roots" element is a JsonValueKind.Object.  My Bookmarks file though has a JsonValueKind.String value off the roots key of `"sync_transaction_version": "20297",` along-side the bookmark_bar, other, and synced keys, which ARE objects.  When it hits that sync_transaction_version string, and calls EnumerateFolderBookmark with it, it gets into the method because it IS a JsonElement, but then throws an exception on the folderElement.TryGetProperty("children", ...) call because you can't call TryGetProperty on a String, only Objects.
This commit is contained in:
Rick 2022-03-08 20:54:54 -05:00 committed by GitHub
parent dd8135edaf
commit 7fe166d18b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -37,7 +37,8 @@ namespace Flow.Launcher.Plugin.BrowserBookmark
return new();
foreach (var folder in rootElement.EnumerateObject())
{
EnumerateFolderBookmark(folder.Value, bookmarks, source);
if (folder.Value.ValueKind == JsonValueKind.Object)
EnumerateFolderBookmark(folder.Value, bookmarks, source);
}
return bookmarks;
}
@ -64,4 +65,4 @@ namespace Flow.Launcher.Plugin.BrowserBookmark
}
}
}
}