Skip to content

Commit

Permalink
create bookmark_bar.json file if its missing
Browse files Browse the repository at this point in the history
  • Loading branch information
ilude committed May 8, 2024
1 parent 927e909 commit 42b4389
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions app/models/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,17 @@ class Layout:
tabs: list[Tab] = []
bookmark_bar: list[dict] = []

def __init__(self, config_file: str = "configs/layout.yml"):
def __init__(self, config_file: str = "configs/layout.yml", bookmarks_bar_file: str = "configs/bookmarks_bar.json"):
self.config_path = pwd.joinpath(config_file)
self.bookmark_bar_path = pwd.joinpath(bookmarks_bar_file)

try:
if not os.path.exists(pwd.joinpath('configs/bookmarks.json')):
with open(pwd.joinpath('configs/bookmarks.json'), 'w', encoding='utf-8') as f:
json.dump([], f)
except Exception as ex:
logger.error(f"Error: {ex} creating empty bookmark bar file at {self.bookmark_bar_path}")

self.favicon_finder = FaviconFinder()
self.reload()

Expand Down Expand Up @@ -71,9 +80,6 @@ def reload(self):
self.bookmark_bar = self.load_bookmarks()

bookmarks = self.bookmark_iterator(self.bookmark_bar)

print(f"================= Found {len(bookmarks)} bookmarks")

self.favicon_finder.fetch_from_iterator(bookmarks)

logger.debug("Completed Layout reload!")
Expand Down

0 comments on commit 42b4389

Please sign in to comment.