Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[jarun#791] added support for absolute paths in Firefox autoimport #792

Merged
merged 1 commit into from
Nov 8, 2024

Conversation

LeXofLeviafan
Copy link
Collaborator

fixes #791:

  • when processing paths for Firefox autoimport, absolute paths are now handled correctly (whether taken from profiles.ini or supplied with FIREFOX_PROFILE=)

Also cleaned up some duplicate code in .auto_import_from_browser().

profiles = firefox_profile or get_firefox_profile_names(default_ff_folder)
if profiles:
ff_bm_db_paths = {s: '~/.mozilla/firefox/{}/places.sqlite'.format(s)
for s in profiles}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This got moved into a separate function, since it's exactly the same processing other than the prefix.
(Also it's easier to test for correctness this way.)

self.load_chrome_database(bookmarks_database, newtag, add_parent_folder_as_tag)
except Exception as e:
LOGERR(e)
print(f'Could not import bookmarks from {name}')
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These 3 blocks were identical, sans the browser name and the DB path

@@ -3612,7 +3569,7 @@ def get_firefox_profile_names(path):
from configparser import ConfigParser, NoOptionError

profiles = []
profile_path = os.path.join(path, 'profiles.ini')
profile_path = os.path.expanduser(os.path.join(path, 'profiles.ini'))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the expansion is necessary either way, it's more reliable to just do it within the function, instead of relying on it be done by the invoking code.

StartWithLastProfile=1
Version=2
'''), ['/path/to/removable/drive/ABCD', 'zsq8tck1.default-release']),
('', []), (None, []),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Paths from Installs, paths from Profiles, empty file, no file.

'/bar/baz': os.path.join('/bar/baz', 'places.sqlite'),
}),
(['foo', '/bar/baz'], 'qux', {'qux': os.path.join('~/profiles', 'qux', 'places.sqlite')}),
([], '/grue/xyzzy', {'/grue/xyzzy': os.path.join('/grue/xyzzy', 'places.sqlite')}),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No custom profile path, directory name, absolute path.

@jarun jarun merged commit 45384c7 into jarun:master Nov 8, 2024
1 check passed
@jarun
Copy link
Owner

jarun commented Nov 8, 2024

Thank you!

@LeXofLeviafan LeXofLeviafan deleted the firefox-abspath-imports branch November 8, 2024 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Autoimport fails to find Firefox profiles & issue with hardcoded profiles path when IsRelative=0
2 participants