lint, comments and interface guards on browsers

This commit is contained in:
blob42 2023-09-09 16:08:34 +02:00
parent bcf917977f
commit 103646828b
4 changed files with 34 additions and 3 deletions

View File

@ -13,6 +13,7 @@ import (
"github.com/buger/jsonparser"
"git.blob42.xyz/gomark/gosuki/database"
"git.blob42.xyz/gomark/gosuki/hooks"
"git.blob42.xyz/gomark/gosuki/logging"
"git.blob42.xyz/gomark/gosuki/modules"
"git.blob42.xyz/gomark/gosuki/tree"
@ -439,3 +440,12 @@ func NewChrome() *Chrome {
func init() {
modules.RegisterBrowser(Chrome{ChromeConfig: ChromeCfg})
}
// interface guards
var _ modules.BrowserModule = (*Chrome)(nil)
var _ modules.Initializer = (*Chrome)(nil)
var _ modules.Loader = (*Chrome)(nil)
var _ watch.WatchRunner = (*Chrome)(nil)
var _ hooks.HookRunner = (*Chrome)(nil)
var _ watch.Stats = (*Chrome)(nil)

View File

@ -12,6 +12,7 @@ import (
"time"
"git.blob42.xyz/gomark/gosuki/database"
"git.blob42.xyz/gomark/gosuki/hooks"
"git.blob42.xyz/gomark/gosuki/logging"
"git.blob42.xyz/gomark/gosuki/modules"
"git.blob42.xyz/gomark/gosuki/mozilla"
@ -329,7 +330,11 @@ func (f *Firefox) Load() error {
return err
}
defer pc.Clean()
defer func(){
if err := pc.Clean(); err != nil {
log.Errorf("error cleaning tmp places file: %s", err)
}
}()
// load all bookmarks
start := time.Now()
@ -677,6 +682,9 @@ func (f *Firefox) initPlacesCopy() (mozilla.PlaceCopyJob, error) {
// init is required to register the module as a plugin when it is imported
func init() {
modules.RegisterBrowser(Firefox{FirefoxConfig: FFConfig})
// Exaple for registering a command under the browser name
//TIP: cmd.RegisterModCommand(BrowserName, &cli.Command{
// Name: "test",
// })
@ -684,3 +692,14 @@ func init() {
// Name: "test2",
// })
}
// interface guards
var _ modules.BrowserModule = (*Firefox)(nil)
var _ modules.Initializer = (*Firefox)(nil)
var _ modules.Loader = (*Firefox)(nil)
var _ modules.Shutdowner = (*Firefox)(nil)
var _ watch.WatchRunner = (*Firefox)(nil)
var _ hooks.HookRunner = (*Firefox)(nil)
var _ watch.Stats = (*Firefox)(nil)
var _ profiles.ProfileManager = (*Firefox)(nil)

View File

@ -143,8 +143,9 @@ func (b BrowserConfig) HasHook(hook hooks.Hook) bool {
//TODO!: use this method instead of manually building bookmark path
// full abosulte path to the bookmark file
// note: this could be non relevant to some browsers
// BookmarkPath returns the absolute path to the bookmark file.
// It expands the path by concatenating the base directory and bookmarks file,
// then checks if it exists.
func (b BrowserConfig) BookmarkPath() (string, error) {
bPath, err := filepath.EvalSymlinks(path.Join(utils.ExpandPath(b.BkDir),
b.BkFile))

View File

@ -86,6 +86,7 @@ func (pm *MozProfileManager) GetProfiles() ([]*profiles.Profile, error) {
return result, nil
}
// GetProfilePath returns the absolute path to a mozilla profile.
func (pm *MozProfileManager) GetProfilePath(name string) (string, error) {
log.Debugf("using config dir %s", pm.ConfigDir)
p, err := pm.GetProfileByName(name)