Fix null app names in macos

This commit is contained in:
qianlifeng 2024-09-20 17:29:24 +08:00
parent 1480a8951b
commit cf9fbc0b17
No known key found for this signature in database
2 changed files with 12 additions and 6 deletions

View File

@ -950,10 +950,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: f652077d0bdf60abe4c1f6377448e8655008eef28f128bc023f7b5e8dfeb48fc
sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
url: "https://pub.dev"
source: hosted
version: "14.2.4"
version: "14.2.5"
web:
dependency: transitive
description:

View File

@ -17,20 +17,22 @@ import (
"crypto/md5"
"errors"
"fmt"
"github.com/disintegration/imaging"
"github.com/mitchellh/go-homedir"
"github.com/tidwall/gjson"
"howett.net/plist"
"image"
"io"
"os"
"os/exec"
"path"
"path/filepath"
"strings"
"sync"
"unsafe"
"wox/plugin"
"wox/util"
"github.com/disintegration/imaging"
"github.com/mitchellh/go-homedir"
"github.com/tidwall/gjson"
"howett.net/plist"
)
var appRetriever = &MacRetriever{}
@ -88,6 +90,10 @@ func (a *MacRetriever) ParseAppInfo(ctx context.Context, path string) (appInfo,
}
appName := strings.TrimSpace(string(out))
if appName == "(null)" {
appName = filepath.Base(path)
a.api.Log(ctx, plugin.LogLevelWarning, fmt.Sprintf("failed to get app name from mdls(%s), using filename instead", path))
}
for _, extension := range a.GetAppExtensions(ctx) {
if strings.HasSuffix(appName, "."+extension) {
appName = appName[:len(appName)-len(extension)-1]