jarun/buku

Firefox auto-import breaks if profile name does not end with .default

shv-q3 opened this issue · 12 comments

Firefox auto-imprt breaks if profile name does not end with .default, with firefox profile name like 4r3pvu9s.default-1478290660929 this happens:

./buku.py --ai
Traceback (most recent call last):
File "./buku.py", line 4338, in
main()
File "./buku.py", line 4288, in main
bdb.auto_import_from_browser()
File "./buku.py", line 2175, in auto_import_from_browser
profile = get_firefox_profile_name(DEFAULT_FF_FOLDER)
File "./buku.py", line 2571, in get_firefox_profile_name
profile = [name[:-8] for name in names if name.endswith('.default')][0]
IndexError: list index out of range

I tested many profile names and all that does not end with .default return error
so the solution could be reading profile names from profiles.ini in mozilla profile folder.
I did tests only on arch linux, dont know for other distros

Thank you for the submitting report. I'll look at this issue. We decided only look for default file names, and I didn't expect that such format exists.

jarun commented

@shv-q3 on which platform is this happening?

@alex-bender from the contents of profiles.ini it seems the default profile comes with a line Default=1. I think we should change get_firefox_profile_name() to return the full Path (from the line Path=6i3qgjrr.default where Default=1) and use it.

jarun commented

@shv-q3 can you please test the patch and confirm it works for you?

@alex-bender I have pushed this interim patch because there was no timeline from you by when you'll be able to fix this critical issue.

If you are interested in implementing reading from the profiles.ini to get the default directory please let me know by when you'll be able to finish it.

@jarun Hi! I would like to take it but I want to discuss it with you first. It was my initial idea to read
profiles.ini file, but we rejected it. Would you be available today for chat?

shv-q3 on which platform is this happening?

I did tests only on arch linux, dont know for other distros

jarun commented

Yes, I wasn't aware of the fact that the ini file says explicitly which is the default profile. As I see it's there, and is a good way to figure out the default profile.

I am not sure when I will be available. Just leave your questions here.

Also, the platform may not be relevant. You can backup your .mozilla directory and make changes inside to match the scenario. As long as you don't run Firefox in between and replace back the original directory everything should be fine.

So do you want me to just parse raw ini file or use configparser module?

jarun commented

Raw parse. No extra deps.

jarun commented

Otherwise, is configparser module installed by default with python? In that case do a local import.

@jarun yeah, it's default module.

do a local import.

Ok

@alex-bender @jarun
I did manage to rewrite get_firefox_profile_name(path) and get it to work but still did not test other distros then linux can you please check it out link to change and let me know what you think

@shv-q3 lets wait jarun. Your comment looks a bit obscure for me.
Also, pay attention that there is a logerr function and use os.paht.join instead of iniprof = path + '/profiles.ini'.

jarun commented

@shv-q3 Alex has raised a review already so I'm checking that. Please feel free to review the PR.