https://bugs.documentfoundation.org/show_bug.cgi?id=147280

--- Comment #2 from Arkadiusz Miƛkiewicz <[email protected]> ---
Changing script to make

mdfind "kMDItemContentType =='com.apple.application-bundle' &&
kMDItemDisplayName == 'LibreOffice.app'"

return nothing is a simple way to reproduce without playing with disabling
spotlight.

Anyway I would go with simplest approach. If spotlight is disabled then mdfind
won't find anything. User will be required to point to LibreOffice.app manually
and what is needed is to make verification of that directory also working in
spotlight-disabled environment.

Code for that is:

-- now only check whether the path is really from LibreOffice
try
        do shell script "mdls --raw --name kMDItemFSName --name kMDItemVersion
" & quoted form of (choice as string) & " | xargs -0 | fgrep 'LibreOffice.app
7.3'"
on error
        display dialog (choice as string) & appInvalid buttons {InstallLabel}
default button 1 with icon 0
        return 3 --wrong target-directory
end try


"mdls  /Applications/LibreOffice.app" on spotlight disabled system doesn't show
"kMDItemVersion"

On mine it is:

arekm@amb ~ % mdls  /Applications/LibreOffice.app
kMDItemFSContentChangeDate = 2022-01-26 18:34:37 +0000
kMDItemFSCreationDate      = 2022-01-26 18:34:37 +0000
kMDItemFSCreatorCode       = ""
kMDItemFSFinderFlags       = 0
kMDItemFSHasCustomIcon     = 0
kMDItemFSInvisible         = 0
kMDItemFSIsExtensionHidden = 0
kMDItemFSIsStationery      = 0
kMDItemFSLabel             = 0
kMDItemFSName              = "LibreOffice.app"
kMDItemFSNodeCount         = 1
kMDItemFSOwnerGroupID      = 80
kMDItemFSOwnerUserID       = 501
kMDItemFSSize              = 1
kMDItemFSTypeCode          = ""
arekm@amb ~ %

so

% mdls --raw --name kMDItemFSName --name kMDItemVersion
/Applications/LibreOffice.app
LibreOffice.app(null)%
arekm@amb ~ %

Maybe change this condition to be like (pseudo apple script since I don't know
it) :

if

"mdls --raw --name kMDItemFSName --name kMDItemVersion " & quoted form of
(choice as string) & " | xargs -0 | fgrep 'LibreOffice.app 7.3'"

OR

(
  "defaults read " & quoted form of (choice as string) & 
  "/LibreOffice.app/Contents/Info CFBundleName == "LibreOffice"

  AND

  defaults read  " & quoted form of (choice as string) & 
  "/LibreOffice.app/Contents/Info CFBundleVersion | xargs -0 | fgrep "^7.3'"

)

That would work for both cases, with and without spotlight.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to