@@ -130,18 +130,41 @@ def ignore_folder_history(folder, serializer)
130130 end
131131
132132 def thunderbird_profile ( name = nil )
133+ Logger . logger . info ( "[CLI::Utils] Fetching Thunderbird profile" )
133134 profiles = ::Thunderbird ::Profiles . new
135+ Logger . logger . debug ( "[CLI::Utils] Found #{ profiles . installs . count } Thunderbird install(s)" )
134136 if name
137+ Logger . logger . debug ( "[CLI::Utils] Using profile name '#{ name } '" )
135138 profiles . profile ( name )
136139 else
137- if profiles . installs . count > 1
138- raise <<~MESSAGE
139- Thunderbird has multiple installs, so no default profile exists.
140- Please supply a profile name
141- MESSAGE
142- end
143-
144- profiles . installs [ 0 ] . default
140+ choose_default_profile ( profiles )
141+ end
142+ end
143+
144+ def choose_default_profile ( profiles )
145+ Logger . logger . debug ( "[CLI::Utils] No profile name supplied, so looking for default profile" )
146+ case profiles . installs . count
147+ when 0
148+ raise "No Thunderbird installs found, so no default profile exists"
149+ when 1
150+ install = profiles . installs . first
151+ Logger . logger . debug (
152+ "[CLI::Utils] Only one Thunderbird install found '#{ install . title } ', " \
153+ "so using its default profile"
154+ )
155+
156+ profile = install . default_profile
157+ raise "Thunderbird install '#{ install . title } ' does not have a default profile" if !profile
158+
159+ Logger . logger . debug (
160+ "[CLI::Utils] Default profile '#{ profile . title } ' has path '#{ profile . root } '"
161+ )
162+ profile
163+ else
164+ raise <<~MESSAGE
165+ Thunderbird has multiple installs, so no default profile exists.
166+ Please supply a profile name
167+ MESSAGE
145168 end
146169 end
147170 end
0 commit comments