mirror of
https://github.com/safing/portmaster
synced 2025-09-01 10:09:11 +00:00
Rename profile/icons to profile/binmeta
This commit is contained in:
parent
a88de1532c
commit
2ae24656fc
23 changed files with 49 additions and 49 deletions
|
@ -10,7 +10,7 @@ import (
|
|||
"github.com/safing/portbase/log"
|
||||
"github.com/safing/portmaster/process"
|
||||
"github.com/safing/portmaster/profile"
|
||||
"github.com/safing/portmaster/profile/icons"
|
||||
"github.com/safing/portmaster/profile/binmeta"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -124,7 +124,7 @@ func (h *AppImageHandler) CreateProfile(p *process.Process) *profile.Profile {
|
|||
if tag, ok := p.GetTag(appImagePathTagKey); ok {
|
||||
return profile.New(&profile.Profile{
|
||||
Source: profile.SourceLocal,
|
||||
Name: icons.GenerateBinaryNameFromPath(p.Path),
|
||||
Name: binmeta.GenerateBinaryNameFromPath(p.Path),
|
||||
PresentationPath: p.Path,
|
||||
UsePresentationPath: true,
|
||||
Fingerprints: []profile.Fingerprint{
|
||||
|
@ -141,7 +141,7 @@ func (h *AppImageHandler) CreateProfile(p *process.Process) *profile.Profile {
|
|||
if tag, ok := p.GetTag(appImageMountIDTagKey); ok {
|
||||
return profile.New(&profile.Profile{
|
||||
Source: profile.SourceLocal,
|
||||
Name: icons.GenerateBinaryNameFromPath(p.Path),
|
||||
Name: binmeta.GenerateBinaryNameFromPath(p.Path),
|
||||
PresentationPath: p.Path,
|
||||
UsePresentationPath: true,
|
||||
Fingerprints: []profile.Fingerprint{
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
|
||||
"github.com/safing/portmaster/process"
|
||||
"github.com/safing/portmaster/profile"
|
||||
"github.com/safing/portmaster/profile/icons"
|
||||
"github.com/safing/portmaster/profile/binmeta"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -69,7 +69,7 @@ func (h *flatpakHandler) CreateProfile(p *process.Process) *profile.Profile {
|
|||
if tag, ok := p.GetTag(flatpakIDTagKey); ok {
|
||||
return profile.New(&profile.Profile{
|
||||
Source: profile.SourceLocal,
|
||||
Name: icons.GenerateBinaryNameFromPath(p.Path),
|
||||
Name: binmeta.GenerateBinaryNameFromPath(p.Path),
|
||||
PresentationPath: p.Path,
|
||||
UsePresentationPath: true,
|
||||
Fingerprints: []profile.Fingerprint{
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
|
||||
"github.com/safing/portmaster/process"
|
||||
"github.com/safing/portmaster/profile"
|
||||
"github.com/safing/portmaster/profile/icons"
|
||||
"github.com/safing/portmaster/profile/binmeta"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -161,7 +161,7 @@ func (h *InterpHandler) CreateProfile(p *process.Process) *profile.Profile {
|
|||
for _, ext := range it.Extensions {
|
||||
scriptName, _ = strings.CutSuffix(scriptName, ext)
|
||||
}
|
||||
scriptName = icons.GenerateBinaryNameFromPath(scriptName)
|
||||
scriptName = binmeta.GenerateBinaryNameFromPath(scriptName)
|
||||
|
||||
return profile.New(&profile.Profile{
|
||||
Source: profile.SourceLocal,
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
|
||||
"github.com/safing/portmaster/process"
|
||||
"github.com/safing/portmaster/profile"
|
||||
"github.com/safing/portmaster/profile/icons"
|
||||
"github.com/safing/portmaster/profile/binmeta"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -117,7 +117,7 @@ func (h *SnapHandler) CreateProfile(p *process.Process) *profile.Profile {
|
|||
|
||||
return profile.New(&profile.Profile{
|
||||
Source: profile.SourceLocal,
|
||||
Name: icons.GenerateBinaryNameFromPath(tag.Value),
|
||||
Name: binmeta.GenerateBinaryNameFromPath(tag.Value),
|
||||
PresentationPath: p.Path,
|
||||
UsePresentationPath: hasVersion,
|
||||
Fingerprints: []profile.Fingerprint{
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
"github.com/safing/portbase/utils/osdetail"
|
||||
"github.com/safing/portmaster/process"
|
||||
"github.com/safing/portmaster/profile"
|
||||
"github.com/safing/portmaster/profile/icons"
|
||||
"github.com/safing/portmaster/profile/binmeta"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -86,7 +86,7 @@ func (h *SVCHostTagHandler) CreateProfile(p *process.Process) *profile.Profile {
|
|||
// Create new profile based on tag.
|
||||
newProfile := profile.New(&profile.Profile{
|
||||
Source: profile.SourceLocal,
|
||||
Name: "Windows Service: " + icons.GenerateBinaryNameFromPath(tag.Value),
|
||||
Name: "Windows Service: " + binmeta.GenerateBinaryNameFromPath(tag.Value),
|
||||
UsePresentationPath: false,
|
||||
Fingerprints: []profile.Fingerprint{
|
||||
{
|
||||
|
@ -99,9 +99,9 @@ func (h *SVCHostTagHandler) CreateProfile(p *process.Process) *profile.Profile {
|
|||
})
|
||||
|
||||
// Load default icon for windows service.
|
||||
icon, err := icons.LoadAndSaveIcon(context.TODO(), `C:\Windows\System32\@WLOGO_48x48.png`)
|
||||
icon, err := binmeta.LoadAndSaveIcon(context.TODO(), `C:\Windows\System32\@WLOGO_48x48.png`)
|
||||
if err == nil {
|
||||
newProfile.Icons = []icons.Icon{*icon}
|
||||
newProfile.Icons = []binmeta.Icon{*icon}
|
||||
}
|
||||
|
||||
return newProfile
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"github.com/safing/portbase/utils"
|
||||
"github.com/safing/portmaster/process"
|
||||
"github.com/safing/portmaster/profile"
|
||||
"github.com/safing/portmaster/profile/icons"
|
||||
"github.com/safing/portmaster/profile/binmeta"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -101,7 +101,7 @@ func (h *WinStoreHandler) CreateProfile(p *process.Process) *profile.Profile {
|
|||
if tag, ok := p.GetTag(winStoreAppNameTagKey); ok {
|
||||
return profile.New(&profile.Profile{
|
||||
Source: profile.SourceLocal,
|
||||
Name: icons.GenerateBinaryNameFromPath(tag.Value),
|
||||
Name: binmeta.GenerateBinaryNameFromPath(tag.Value),
|
||||
PresentationPath: p.Path,
|
||||
UsePresentationPath: true,
|
||||
Fingerprints: []profile.Fingerprint{
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"github.com/safing/portbase/api"
|
||||
"github.com/safing/portbase/formats/dsd"
|
||||
"github.com/safing/portbase/utils"
|
||||
"github.com/safing/portmaster/profile/icons"
|
||||
"github.com/safing/portmaster/profile/binmeta"
|
||||
)
|
||||
|
||||
func registerAPIEndpoints() error {
|
||||
|
@ -99,7 +99,7 @@ func handleGetProfileIcon(ar *api.Request) (data []byte, err error) {
|
|||
ext := filepath.Ext(name)
|
||||
|
||||
// Get profile icon.
|
||||
data, err = icons.GetProfileIcon(name)
|
||||
data, err = binmeta.GetProfileIcon(name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ func handleUpdateProfileIcon(ar *api.Request) (any, error) {
|
|||
}
|
||||
|
||||
// Update profile icon.
|
||||
filename, err := icons.UpdateProfileIcon(ar.InputData, ext)
|
||||
filename, err := binmeta.UpdateProfileIcon(ar.InputData, ext)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package icons
|
||||
package binmeta
|
||||
|
||||
import (
|
||||
"bytes"
|
|
@ -1,6 +1,6 @@
|
|||
//go:build !linux && !windows
|
||||
|
||||
package icons
|
||||
package binmeta
|
||||
|
||||
import "context"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package icons
|
||||
package binmeta
|
||||
|
||||
import (
|
||||
"context"
|
|
@ -1,4 +1,4 @@
|
|||
package icons
|
||||
package binmeta
|
||||
|
||||
import (
|
||||
"os"
|
|
@ -1,4 +1,4 @@
|
|||
package icons
|
||||
package binmeta
|
||||
|
||||
import (
|
||||
"bytes"
|
|
@ -1,4 +1,4 @@
|
|||
package icons
|
||||
package binmeta
|
||||
|
||||
import (
|
||||
"context"
|
|
@ -1,4 +1,4 @@
|
|||
package icons
|
||||
package binmeta
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
@ -42,8 +42,8 @@ func (t IconType) sortOrder() int {
|
|||
}
|
||||
}
|
||||
|
||||
// SortAndCompact sorts and compacts a list of icons.
|
||||
func SortAndCompact(icons []Icon) []Icon {
|
||||
// SortAndCompactIcons sorts and compacts a list of icons.
|
||||
func SortAndCompactIcons(icons []Icon) []Icon {
|
||||
// Sort.
|
||||
slices.SortFunc[[]Icon, Icon](icons, func(a, b Icon) int {
|
||||
aOrder := a.Type.sortOrder()
|
|
@ -1,4 +1,4 @@
|
|||
package icons
|
||||
package binmeta
|
||||
|
||||
import (
|
||||
"context"
|
|
@ -1,4 +1,4 @@
|
|||
package icons
|
||||
package binmeta
|
||||
|
||||
import (
|
||||
"fmt"
|
|
@ -1,4 +1,4 @@
|
|||
package icons
|
||||
package binmeta
|
||||
|
||||
import (
|
||||
"path/filepath"
|
|
@ -1,4 +1,4 @@
|
|||
package icons
|
||||
package binmeta
|
||||
|
||||
import (
|
||||
"testing"
|
|
@ -7,7 +7,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/safing/portbase/database/record"
|
||||
"github.com/safing/portmaster/profile/icons"
|
||||
"github.com/safing/portmaster/profile/binmeta"
|
||||
)
|
||||
|
||||
// MergeProfiles merges multiple profiles into a new one.
|
||||
|
@ -52,12 +52,12 @@ func MergeProfiles(name string, primary *Profile, secondaries ...*Profile) (newP
|
|||
}
|
||||
|
||||
// Collect all icons.
|
||||
newProfile.Icons = make([]icons.Icon, 0, len(secondaries)+1) // Guess the needed space.
|
||||
newProfile.Icons = make([]binmeta.Icon, 0, len(secondaries)+1) // Guess the needed space.
|
||||
newProfile.Icons = append(newProfile.Icons, primary.Icons...)
|
||||
for _, sp := range secondaries {
|
||||
newProfile.Icons = append(newProfile.Icons, sp.Icons...)
|
||||
}
|
||||
newProfile.Icons = icons.SortAndCompact(newProfile.Icons)
|
||||
newProfile.Icons = binmeta.SortAndCompactIcons(newProfile.Icons)
|
||||
|
||||
// Collect all fingerprints.
|
||||
newProfile.Fingerprints = make([]Fingerprint, 0, len(primary.Fingerprints)+len(secondaries)) // Guess the needed space.
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
"github.com/safing/portbase/database/migration"
|
||||
"github.com/safing/portbase/database/query"
|
||||
"github.com/safing/portbase/log"
|
||||
"github.com/safing/portmaster/profile/icons"
|
||||
"github.com/safing/portmaster/profile/binmeta"
|
||||
)
|
||||
|
||||
func registerMigrations() error {
|
||||
|
@ -103,7 +103,7 @@ func migrateIcons(ctx context.Context, _, to *version.Version, db *database.Inte
|
|||
}
|
||||
|
||||
// Migrate to icon list.
|
||||
profile.Icons = []icons.Icon{{
|
||||
profile.Icons = []binmeta.Icon{{
|
||||
Type: profile.IconType,
|
||||
Value: profile.Icon,
|
||||
}}
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
"github.com/safing/portbase/log"
|
||||
"github.com/safing/portbase/modules"
|
||||
_ "github.com/safing/portmaster/core/base"
|
||||
"github.com/safing/portmaster/profile/icons"
|
||||
"github.com/safing/portmaster/profile/binmeta"
|
||||
"github.com/safing/portmaster/updates"
|
||||
)
|
||||
|
||||
|
@ -53,7 +53,7 @@ func prep() error {
|
|||
if err := iconsDir.Ensure(); err != nil {
|
||||
return fmt.Errorf("failed to create/check icons directory: %w", err)
|
||||
}
|
||||
icons.ProfileIconStoragePath = iconsDir.Path
|
||||
binmeta.ProfileIconStoragePath = iconsDir.Path
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -16,8 +16,8 @@ import (
|
|||
"github.com/safing/portbase/log"
|
||||
"github.com/safing/portbase/utils"
|
||||
"github.com/safing/portmaster/intel/filterlists"
|
||||
"github.com/safing/portmaster/profile/binmeta"
|
||||
"github.com/safing/portmaster/profile/endpoints"
|
||||
"github.com/safing/portmaster/profile/icons"
|
||||
)
|
||||
|
||||
// ProfileSource is the source of the profile.
|
||||
|
@ -68,9 +68,9 @@ type Profile struct { //nolint:maligned // not worth the effort
|
|||
// See IconType for more information.
|
||||
Icon string
|
||||
// Deprecated: IconType describes the type of the Icon property.
|
||||
IconType icons.IconType
|
||||
IconType binmeta.IconType
|
||||
// Icons holds a list of icons to represent the application.
|
||||
Icons []icons.Icon
|
||||
Icons []binmeta.Icon
|
||||
|
||||
// Deprecated: LinkedPath used to point to the executableis this
|
||||
// profile was created for.
|
||||
|
@ -469,7 +469,7 @@ func (profile *Profile) updateMetadata(binaryPath string) (changed bool) {
|
|||
// Set Name if unset.
|
||||
if profile.Name == "" && profile.PresentationPath != "" {
|
||||
// Generate a default profile name from path.
|
||||
profile.Name = icons.GenerateBinaryNameFromPath(profile.PresentationPath)
|
||||
profile.Name = binmeta.GenerateBinaryNameFromPath(profile.PresentationPath)
|
||||
changed = true
|
||||
}
|
||||
|
||||
|
@ -514,7 +514,7 @@ func (profile *Profile) updateMetadataFromSystem(ctx context.Context, md Matchin
|
|||
}
|
||||
|
||||
// Get binary icon and name.
|
||||
newIcon, newName, err := icons.GetIconAndName(ctx, profile.PresentationPath, home)
|
||||
newIcon, newName, err := binmeta.GetIconAndName(ctx, profile.PresentationPath, home)
|
||||
if err != nil {
|
||||
log.Warningf("profile: failed to get binary icon/name for %s: %s", profile.PresentationPath, err)
|
||||
}
|
||||
|
@ -534,10 +534,10 @@ func (profile *Profile) updateMetadataFromSystem(ctx context.Context, md Matchin
|
|||
// Apply new icon if found.
|
||||
if newIcon != nil {
|
||||
if len(profile.Icons) == 0 {
|
||||
profile.Icons = []icons.Icon{*newIcon}
|
||||
profile.Icons = []binmeta.Icon{*newIcon}
|
||||
} else {
|
||||
profile.Icons = append(profile.Icons, *newIcon)
|
||||
profile.Icons = icons.SortAndCompact(profile.Icons)
|
||||
profile.Icons = binmeta.SortAndCompactIcons(profile.Icons)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
"github.com/safing/portbase/config"
|
||||
"github.com/safing/portbase/log"
|
||||
"github.com/safing/portmaster/profile"
|
||||
"github.com/safing/portmaster/profile/icons"
|
||||
"github.com/safing/portmaster/profile/binmeta"
|
||||
)
|
||||
|
||||
// ProfileExport holds an export of a profile.
|
||||
|
@ -415,12 +415,12 @@ func ImportProfile(r *ProfileImportRequest, requiredProfileSource profile.Profil
|
|||
if err != nil {
|
||||
return nil, fmt.Errorf("%w: icon data is invalid: %w", ErrImportFailed, err)
|
||||
}
|
||||
filename, err := icons.UpdateProfileIcon(du.Data, du.MediaType.Subtype)
|
||||
filename, err := binmeta.UpdateProfileIcon(du.Data, du.MediaType.Subtype)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%w: icon is invalid: %w", ErrImportFailed, err)
|
||||
}
|
||||
p.Icons = []icons.Icon{{
|
||||
Type: icons.IconTypeAPI,
|
||||
p.Icons = []binmeta.Icon{{
|
||||
Type: binmeta.IconTypeAPI,
|
||||
Value: filename,
|
||||
}}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue