gosuki/firefox.go

659 lines
16 KiB
Go
Raw Normal View History

2022-09-20 10:11:16 +00:00
// TODO: unit test critical error should shutdown the browser
// TODO: shutdown procedure (also close reducer)
2018-06-08 16:27:33 +00:00
package main
import (
2018-11-05 01:40:11 +00:00
"database/sql"
2019-02-22 18:50:26 +00:00
"errors"
2019-03-01 17:30:50 +00:00
"fmt"
2018-06-14 14:42:54 +00:00
"path"
2018-11-20 17:33:37 +00:00
"path/filepath"
2018-10-25 16:09:03 +00:00
"time"
2020-11-06 17:50:36 +00:00
"git.sp4ke.xyz/sp4ke/gomark/browsers"
"git.sp4ke.xyz/sp4ke/gomark/database"
"git.sp4ke.xyz/sp4ke/gomark/mozilla"
"git.sp4ke.xyz/sp4ke/gomark/parsing"
"git.sp4ke.xyz/sp4ke/gomark/tree"
"git.sp4ke.xyz/sp4ke/gomark/utils"
"git.sp4ke.xyz/sp4ke/gomark/watch"
2020-08-12 18:13:01 +00:00
2018-11-02 17:21:18 +00:00
"github.com/fsnotify/fsnotify"
2018-11-23 03:40:10 +00:00
"github.com/jmoiron/sqlx"
sqlite3 "github.com/mattn/go-sqlite3"
)
2018-11-13 16:11:16 +00:00
const (
QGetBookmarkPlace = `
2018-11-23 03:40:10 +00:00
SELECT *
2018-11-13 17:21:02 +00:00
FROM moz_places
WHERE id = ?
`
//TEST:
2018-11-23 03:40:10 +00:00
QBookmarksChanged = `
SELECT id,type,IFNULL(fk, -1) AS fk,parent,IFNULL(title, '') AS title from moz_bookmarks
2018-11-23 03:40:10 +00:00
WHERE(lastModified > :last_runtime_utc
AND lastModified < strftime('%s', 'now')*1000*1000
2018-11-23 03:40:10 +00:00
AND NOT id IN (:not_root_tags)
2018-11-13 16:11:16 +00:00
)
`
//TEST:
2018-11-13 16:11:16 +00:00
QGetBookmarks = `WITH bookmarks AS
(SELECT moz_places.url AS url,
moz_places.description as desc,
moz_places.title as urlTitle,
moz_bookmarks.parent AS tagId
FROM moz_places LEFT OUTER JOIN moz_bookmarks
ON moz_places.id = moz_bookmarks.fk
WHERE moz_bookmarks.parent
IN (SELECT id FROM moz_bookmarks WHERE parent = ? ))
SELECT url, IFNULL(urlTitle, ''), IFNULL(desc,''),
tagId, moz_bookmarks.title AS tagTitle
FROM bookmarks LEFT OUTER JOIN moz_bookmarks
ON tagId = moz_bookmarks.id
ORDER BY url`
//TEST:
//TODO:
QGetBookmarkFolders = `
SELECT
moz_places.id as placesId,
moz_places.url as url,
moz_places.description as description,
moz_bookmarks.title as title,
moz_bookmarks.fk ISNULL as isFolder
FROM moz_bookmarks LEFT OUTER JOIN moz_places
ON moz_places.id = moz_bookmarks.fk
WHERE moz_bookmarks.parent = 3
`
2018-11-13 16:11:16 +00:00
)
var ErrInitFirefox = errors.New("Could not start Firefox watcher")
2018-06-08 16:27:33 +00:00
const (
MozMinJobInterval = 1500 * time.Millisecond
)
2018-06-08 16:27:33 +00:00
type FFBrowser struct {
BaseBrowser // embedding
2018-11-13 17:21:02 +00:00
places *database.DB
2018-11-13 16:11:16 +00:00
URLIndexList []string // All elements stored in URLIndex
// Map from places tag IDs to the parse node tree
tagMap map[sqlid]*tree.Node
lastRunTime time.Time
}
// moz_bookmarks.type
2018-11-10 12:22:07 +00:00
const (
_ = iota
BkTypeURL
BkTypeTagFolder
)
type sqlid int64
2018-11-10 12:22:07 +00:00
// moz_bookmarks.id
2018-11-10 12:22:07 +00:00
const (
_ = iota // 0
ffBkRoot // 1
ffBkMenu // 2 Main bookmarks menu
ffBkToolbar // 3 Bk tookbar that can be toggled under URL zone
ffBkTags // 4 Hidden menu used for tags, stored as a flat one level menu
ffBkOther // 5 Most bookmarks are automatically stored here
ffBkMobile // 6 Mobile bookmarks stored here by default
2018-11-10 12:22:07 +00:00
)
2018-11-23 03:40:10 +00:00
type AutoIncr struct {
ID sqlid
}
2018-11-13 16:11:16 +00:00
type FFPlace struct {
URL string `db:"url"`
Description sql.NullString `db:"description"`
Title sql.NullString `db:"title"`
2018-11-23 03:40:10 +00:00
AutoIncr
2018-06-08 16:27:33 +00:00
}
2018-11-23 03:40:10 +00:00
//type FFBookmark struct {
//BType int `db:type`
//Parent sqlid
//FK sql.NullInt64
//Title sql.NullString
//AutoIncr
//}
2018-11-10 12:22:07 +00:00
type FFBookmark struct {
btype sqlid
2018-11-23 03:40:10 +00:00
parent sqlid
fk sqlid
2018-11-13 16:11:16 +00:00
title string
2018-11-23 03:40:10 +00:00
id sqlid
2018-11-10 12:22:07 +00:00
}
func FFPlacesUpdateHook(op int, db string, table string, rowid int64) {
2018-11-09 17:25:50 +00:00
fflog.Debug(op)
}
// TEST: Test browser creation errors
2018-12-04 17:06:30 +00:00
// In case of critical errors degrade the browser to only log errors and disable
// all directives
2018-06-08 16:27:33 +00:00
func NewFFBrowser() IBrowser {
browser := &FFBrowser{
BaseBrowser: browsers.BaseBrowser{
Name: "firefox",
Type: browsers.TFirefox,
BkFile: mozilla.BookmarkFile,
BaseDir: mozilla.GetBookmarkDir(),
NodeTree: &tree.Node{Name: "root", Parent: nil, Type: "root"},
Stats: &parsing.Stats{},
UseFileWatcher: true,
},
tagMap: make(map[sqlid]*tree.Node),
}
2019-03-01 17:30:50 +00:00
return browser
}
func (bw *FFBrowser) Shutdown() {
2019-03-01 18:03:48 +00:00
fflog.Debugf("shutting down ... ")
if bw.places != nil {
err := bw.places.Close()
if err != nil {
fflog.Critical(err)
}
2019-03-01 17:30:50 +00:00
}
bw.BaseBrowser.Shutdown()
}
func (bw *FFBrowser) Watch() bool {
2019-03-01 18:41:44 +00:00
if !bw.IsWatching {
2019-03-01 17:30:50 +00:00
go watch.WatcherThread(bw)
2019-03-01 18:41:44 +00:00
bw.IsWatching = true
for _, v := range bw.WatchedPaths {
fflog.Infof("Watching %s", v)
}
2019-03-01 17:30:50 +00:00
return true
}
return false
}
func (browser *FFBrowser) copyPlacesToTmp() error {
err := utils.CopyFilesToTmpFolder(path.Join(browser.BaseDir, browser.BkFile+"*"))
if err != nil {
return err
}
return nil
}
func (browser *FFBrowser) getPathToPlacesCopy() string {
return path.Join(utils.TMPDIR, browser.BkFile)
}
// TEST:
// HACK: addUrl and addTag share a lot of code, find a way to reuse shared code
// and only pass extra details about tag/url along in some data structure
// PROBLEM: tag nodes use IDs and URL nodes use URL as hashes
func (browser *FFBrowser) addUrlNode(url, title, desc string) (bool, *tree.Node) {
var urlNode *tree.Node
iUrlNode, exists := browser.URLIndex.Get(url)
if !exists {
urlNode := &tree.Node{
Name: title,
Type: "url",
URL: url,
Desc: desc,
}
fflog.Debugf("inserting url %s in url index", url)
browser.URLIndex.Insert(url, urlNode)
browser.URLIndexList = append(browser.URLIndexList, url)
return true, urlNode
} else {
urlNode = iUrlNode.(*tree.Node)
}
return false, urlNode
}
// adds a new tagNode if it is not existing in the tagMap
// returns true if tag added or false if already existing
// returns the created tagNode
func (browser *FFBrowser) addTagNode(tagId sqlid, tagName string) (bool, *tree.Node) {
// node, exists :=
node, exists := browser.tagMap[tagId]
if exists {
return false, node
}
tagNode := &tree.Node{
Name: tagName,
Type: "tag",
Parent: browser.NodeTree, // root node
}
tree.AddChild(browser.NodeTree, tagNode)
browser.tagMap[tagId] = tagNode
browser.Stats.CurrentNodeCount++
return true, tagNode
}
func (browser *FFBrowser) InitPlacesCopy() error {
// Copy places.sqlite to tmp dir
err := browser.copyPlacesToTmp()
if err != nil {
return fmt.Errorf("Could not copy places.sqlite to tmp folder: %s",
err)
}
opts := mozilla.Config.PlacesDSN
browser.places, err = database.New("places",
// using the copied places file instead of the original to avoid
// sqlite vfs lock errors
browser.getPathToPlacesCopy(),
database.DBTypeFileDSN, opts).Init()
if err != nil {
return err
}
return nil
}
2019-03-01 17:30:50 +00:00
func (browser *FFBrowser) Init() error {
2019-03-01 18:41:44 +00:00
bookmarkPath := path.Join(browser.BaseDir, browser.BkFile)
2018-12-04 03:34:30 +00:00
2019-02-22 18:50:26 +00:00
// Check if BookmarkPath exists
exists, err := utils.CheckFileExists(bookmarkPath)
if err != nil {
log.Critical(err)
2019-03-01 17:30:50 +00:00
return ErrInitFirefox
2019-02-22 18:50:26 +00:00
}
2019-03-01 17:30:50 +00:00
2019-02-22 18:50:26 +00:00
if !exists {
2019-03-01 17:30:50 +00:00
return fmt.Errorf("Bookmark path <%s> does not exist", bookmarkPath)
2019-02-22 18:50:26 +00:00
}
err = browser.InitPlacesCopy()
if err != nil {
return err
}
2018-11-02 17:21:18 +00:00
// Setup watcher
2019-03-01 18:41:44 +00:00
expandedBaseDir, err := filepath.EvalSymlinks(browser.BaseDir)
2018-11-20 17:33:37 +00:00
if err != nil {
2019-03-01 17:30:50 +00:00
return err
2018-11-20 17:33:37 +00:00
}
browser.WatchedPaths = []string{filepath.Join(expandedBaseDir, "places.sqlite-wal")}
2019-03-01 18:41:44 +00:00
w := &watch.Watch{
2018-11-20 17:33:37 +00:00
Path: expandedBaseDir,
2018-11-09 17:25:50 +00:00
EventTypes: []fsnotify.Op{fsnotify.Write},
EventNames: browser.WatchedPaths,
2018-11-09 17:25:50 +00:00
ResetWatch: false,
2018-11-02 17:21:18 +00:00
}
browser.SetupFileWatcher(w)
/*
2018-11-02 17:21:18 +00:00
*Run reducer to avoid duplicate running of jobs
*when a batch of events is received
*/
2019-03-01 18:41:44 +00:00
browser.InitEventsChan()
2018-11-02 17:21:18 +00:00
2019-03-01 18:41:44 +00:00
go utils.ReduceEvents(MozMinJobInterval, browser.EventsChan(), browser)
2019-03-01 17:30:50 +00:00
// Base browser init
err = browser.BaseBrowser.Init()
2018-11-13 16:11:16 +00:00
2019-03-01 17:30:50 +00:00
return err
2018-06-08 16:27:33 +00:00
}
2019-03-01 17:30:50 +00:00
func (bw *FFBrowser) Load() error {
err := bw.BaseBrowser.Load()
2018-10-28 19:19:12 +00:00
if err != nil {
2019-03-01 17:30:50 +00:00
return err
2018-10-28 19:19:12 +00:00
}
// Parse bookmarks to a flat tree (for compatibility with tree system)
start := time.Now()
GetFFBookmarks(bw)
2018-11-13 16:11:16 +00:00
bw.Stats.LastFullTreeParseTime = time.Since(start)
2018-11-05 01:40:11 +00:00
bw.lastRunTime = time.Now().UTC()
2018-11-09 17:25:50 +00:00
fflog.Debugf("parsed %d bookmarks and %d nodes in %s",
bw.Stats.CurrentUrlCount,
bw.Stats.CurrentNodeCount,
2018-11-13 16:11:16 +00:00
bw.Stats.LastFullTreeParseTime)
bw.ResetStats()
2018-11-05 01:40:11 +00:00
// Sync the URLIndex to the buffer
// We do not use the NodeTree here as firefox tags are represented
// as a flat tree which is not efficient, we use the go hashmap instead
2018-11-09 17:25:50 +00:00
database.SyncURLIndexToBuffer(bw.URLIndexList, bw.URLIndex, bw.BufferDB)
2018-06-08 16:27:33 +00:00
2018-11-13 16:11:16 +00:00
// Handle empty cache
if empty, err := CacheDB.IsEmpty(); empty {
if err != nil {
fflog.Error(err)
}
fflog.Info("cache empty: loading buffer to Cachedb")
2018-11-13 16:11:16 +00:00
bw.BufferDB.CopyTo(CacheDB)
2018-11-13 16:11:16 +00:00
fflog.Debugf("syncing <%s> to disk", CacheDB.Name)
} else {
bw.BufferDB.SyncTo(CacheDB)
}
go CacheDB.SyncToDisk(database.GetDBFullPath())
2019-03-01 17:30:50 +00:00
go tree.PrintTree(bw.NodeTree)
// Close the copy places.sqlite
err = bw.places.Close()
2019-03-01 17:30:50 +00:00
return err
2018-11-13 16:11:16 +00:00
}
// load all bookmarks from `places.sqlite` and store them in BaseBrowser.NodeTree
// this method is used the first time gomark is started or to extract bookmarks
// using a command
func GetFFBookmarks(bw *FFBrowser) {
fflog.Debugf("root tree children len is %d", len(bw.NodeTree.Children))
//QGetTags := "SELECT id,title from moz_bookmarks WHERE parent = %d"
2018-11-20 17:33:37 +00:00
//
2018-11-10 12:22:07 +00:00
rows, err := bw.places.Handle.Query(QGetBookmarks, ffBkTags)
2020-09-01 12:43:01 +00:00
if err != nil {
log.Fatal(err)
}
// Locked database is critical
if e, ok := err.(sqlite3.Error); ok {
if e.Code == sqlite3.ErrBusy {
fflog.Critical(err)
bw.Shutdown()
return
}
}
2018-10-28 19:19:12 +00:00
if err != nil {
2018-11-20 17:33:37 +00:00
fflog.Errorf("%s: %s", bw.places.Name, err)
return
2018-10-28 19:19:12 +00:00
}
// Rebuilding node tree
// Note: the node tree is built only for compatilibity with tree based
// bookmark parsing and might later be useful for debug/UI features.
// For efficiency reading after the initial Load() from
2018-11-13 18:54:20 +00:00
// places.sqlite should be done using a loop instad of tree traversal.
2018-10-26 01:04:26 +00:00
/*
*This pass is used only for fetching bookmarks from firefox.
*Checking against the URLIndex should not be done here
*/
for rows.Next() {
var url, title, tagTitle, desc string
2018-11-23 03:40:10 +00:00
var tagId sqlid
err = rows.Scan(&url, &title, &desc, &tagId, &tagTitle)
// fflog.Debugf("%s|%s|%s|%d|%s", url, title, desc, tagId, tagTitle)
2018-10-28 19:19:12 +00:00
if err != nil {
2018-11-09 17:25:50 +00:00
fflog.Error(err)
2018-10-28 19:19:12 +00:00
}
/*
* If this is the first time we see this tag
* add it to the tagMap and create its node
*/
ok, tagNode := bw.addTagNode(tagId, tagTitle)
if !ok {
fflog.Infof("tag <%s> already in tag map", tagNode.Name)
}
// Add the url to the tag
ok, urlNode := bw.addUrlNode(url, title, desc)
if !ok {
fflog.Infof("url <%s> already in url index", url)
2018-10-26 01:04:26 +00:00
}
// Add tag name to urlnode tags
2018-10-26 01:04:26 +00:00
urlNode.Tags = append(urlNode.Tags, tagNode.Name)
2018-10-26 01:04:26 +00:00
// Set tag as parent to urlnode
tree.AddChild(bw.tagMap[tagId], urlNode)
2018-11-09 17:25:50 +00:00
bw.Stats.CurrentUrlCount++
}
fflog.Debugf("root tree children len is %d", len(bw.NodeTree.Children))
2018-11-13 16:11:16 +00:00
}
2018-10-26 01:04:26 +00:00
// fetchUrlChanges method 
// scan rows from a firefox `places.sqlite` db and extract all bookmarks and
// places (moz_bookmarks, moz_places tables) that changed/are new since the browser.lastRunTime
// using the QBookmarksChanged query
2018-11-13 16:11:16 +00:00
func (bw *FFBrowser) fetchUrlChanges(rows *sql.Rows,
2018-11-23 03:40:10 +00:00
bookmarks map[sqlid]*FFBookmark,
places map[sqlid]*FFPlace,
) {
bk := &FFBookmark{}
2018-11-13 16:11:16 +00:00
// Get the URL that changed
err := rows.Scan(&bk.id, &bk.btype, &bk.fk, &bk.parent, &bk.title)
if err != nil {
log.Fatal(err)
}
// database.DebugPrintRow(rows)
2018-11-13 16:11:16 +00:00
// We found URL change, urls are specified by
// type == 1
// fk -> id of url in moz_places
// parent == tag id
//
// Each tag on a url generates 2 or 3 entries in moz_bookmarks
// 1. If not existing, a (type==2) entry for the tag itself
// 2. A (type==1) entry for the bookmakred url with (fk -> moz_places.id)
// 3. A (type==1) (fk-> moz_places.id) (parent == idOf(tag))
2018-11-13 16:11:16 +00:00
if bk.btype == BkTypeURL {
2018-11-23 03:40:10 +00:00
var place FFPlace
// Use unsafe db to ignore non existant columns in
// dest field
udb := bw.places.Handle.Unsafe()
err := udb.QueryRowx(QGetBookmarkPlace, bk.fk).StructScan(&place)
if err != nil {
log.Fatal(err)
}
2018-11-23 03:40:10 +00:00
fflog.Debugf("Changed URL: %s", place.URL)
fflog.Debugf("%v", place)
2018-11-13 16:11:16 +00:00
// put url in the places map
2018-11-23 03:40:10 +00:00
places[place.ID] = &place
2018-11-13 16:11:16 +00:00
}
2018-10-26 01:04:26 +00:00
2018-11-13 16:11:16 +00:00
// This is the tag link
if bk.btype == BkTypeURL &&
bk.parent > ffBkMobile {
bookmarks[bk.id] = bk
}
2018-10-26 01:04:26 +00:00
2018-11-13 16:11:16 +00:00
// Tags are specified by:
// type == 2
// parent == (Id of root )
if bk.btype == BkTypeTagFolder {
bookmarks[bk.id] = bk
}
2018-11-13 16:11:16 +00:00
for rows.Next() {
bw.fetchUrlChanges(rows, bookmarks, places)
}
fflog.Debugf("fetching changes done !")
}
2018-06-08 16:27:33 +00:00
func (bw *FFBrowser) Run() {
startRun := time.Now()
2018-11-05 01:40:11 +00:00
err := bw.InitPlacesCopy()
if err != nil {
fflog.Error(err)
}
fflog.Debugf("Checking changes since <%d> %s",
bw.lastRunTime.UTC().UnixNano()/1000,
bw.lastRunTime.Local().Format("Mon Jan 2 15:04:05 MST 2006"))
2018-11-13 16:11:16 +00:00
2018-11-23 03:40:10 +00:00
queryArgs := map[string]interface{}{
"not_root_tags": []int{ffBkRoot, ffBkTags},
"last_runtime_utc": bw.lastRunTime.UTC().UnixNano() / 1000,
}
2018-11-13 16:11:16 +00:00
2018-11-23 03:40:10 +00:00
query, args, err := sqlx.Named(
QBookmarksChanged,
queryArgs,
2018-11-13 16:11:16 +00:00
)
2018-11-05 01:40:11 +00:00
if err != nil {
2018-11-09 17:25:50 +00:00
fflog.Error(err)
2018-11-05 01:40:11 +00:00
}
2018-11-23 03:40:10 +00:00
query, args, err = sqlx.In(query, args...)
if err != nil {
fflog.Error(err)
}
query = bw.places.Handle.Rebind(query)
utils.PrettyPrint(query)
2018-11-05 01:40:11 +00:00
rows, err := bw.places.Handle.Query(query, args...)
2018-11-23 03:40:10 +00:00
if err != nil {
fflog.Error(err)
}
2018-11-05 01:40:11 +00:00
// Found new results in places db since last time we had changes
// database.DebugPrintRows(rows) // WARN: This will disable reading rows
// TEST: implement this in a func and unit test it
// NOTE: this looks like a lot of code reuse in fetchUrlChanges()
for rows.Next() {
// next := rows.Next()
// fflog.Debug("next rows is: ", next)
// if !next {
// break
// }
2018-11-13 16:11:16 +00:00
changedURLS := make([]string, 0)
2018-11-10 12:22:07 +00:00
fflog.Debugf("Found changes since: %s",
bw.lastRunTime.Local().Format("Mon Jan 2 15:04:05 MST 2006"))
2018-11-13 16:11:16 +00:00
// extract bookmarks to this map
2018-11-23 03:40:10 +00:00
bookmarks := make(map[sqlid]*FFBookmark)
// record new places to this map
2018-11-23 03:40:10 +00:00
places := make(map[sqlid]*FFPlace)
2018-11-13 16:11:16 +00:00
// Fetch all changes into bookmarks and places maps
bw.fetchUrlChanges(rows, bookmarks, places)
// utils.PrettyPrint(places)
2018-11-13 16:11:16 +00:00
// For each url
for urlId, place := range places {
var urlNode *tree.Node
changedURLS = utils.Extends(changedURLS, place.URL)
ok, urlNode := bw.addUrlNode(place.URL, place.Title.String, place.Description.String)
if !ok {
fflog.Infof("url <%s> already in url index", place.URL)
2018-11-13 16:11:16 +00:00
}
// First get any new bookmarks
2018-11-13 16:11:16 +00:00
for bkId, bk := range bookmarks {
// if bookmark type is folder or tag
2018-11-13 16:11:16 +00:00
if bk.btype == BkTypeTagFolder &&
// Ignore root directories
// NOTE: ffBkTags change time shows last time bookmark tags
// whre changed ?
bkId != ffBkTags {
fflog.Debugf("adding tag node %s", bk.title)
ok, tagNode := bw.addTagNode(bkId, bk.title)
if !ok {
fflog.Infof("tag <%s> already in tag map", tagNode.Name)
2018-11-13 16:11:16 +00:00
}
}
}
// link tags(moz_bookmark) to urls (moz_places)
2018-11-13 16:11:16 +00:00
for _, bk := range bookmarks {
// This effectively applies the tag to the URL
// The tag link should have a parent over 6 and fk->urlId
fflog.Debugf("Bookmark parent %d", bk.parent)
if bk.fk == urlId &&
bk.parent > ffBkMobile {
// The tag node should have already been created
tagNode, tagNodeExists := bw.tagMap[bk.parent]
2018-11-13 16:11:16 +00:00
if tagNodeExists && urlNode != nil {
fflog.Debugf("URL has tag %s", tagNode.Name)
2018-11-13 16:11:16 +00:00
urlNode.Tags = utils.Extends(urlNode.Tags, tagNode.Name)
2018-11-13 16:11:16 +00:00
tree.AddChild(bw.tagMap[bk.parent], urlNode)
//TEST: remove after testing this code section
// urlNode.Parent = bw.tagMap[bk.parent]
// tree.Insert(bw.tagMap[bk.parent].Children, urlNode)
2018-11-13 16:11:16 +00:00
bw.Stats.CurrentUrlCount++
}
}
}
}
database.SyncURLIndexToBuffer(changedURLS, bw.URLIndex, bw.BufferDB)
bw.BufferDB.SyncTo(CacheDB)
CacheDB.SyncToDisk(database.GetDBFullPath())
2018-11-05 01:40:11 +00:00
}
err = rows.Close()
if err != nil {
fflog.Error(err)
}
2018-11-05 01:40:11 +00:00
// TODO: change logger for more granular debugging
2018-06-08 16:27:33 +00:00
2018-11-13 16:11:16 +00:00
bw.Stats.LastWatchRunTime = time.Since(startRun)
// fflog.Debugf("execution time %s", time.Since(startRun))
// go tree.PrintTree(bw.NodeTree) // debugging
err = bw.places.Close()
if err != nil {
fflog.Error(err)
}
bw.lastRunTime = time.Now().UTC()
2018-06-08 16:27:33 +00:00
}