10000 Fix some more issues by wizzomafizzo · Pull Request #222 · ZaparooProject/zaparoo-core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix some more issues #222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Apr 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions pkg/api/methods/media.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ func (s *IndexingStatus) GenerateMediaDB(
if err != nil {
s.CurrentDesc = status.SystemId
} else {
md, err := assets.GetSystemMetadata(system.Id)
md, err := assets.GetSystemMetadata(system.ID)
if err != nil {
s.CurrentDesc = system.Id
s.CurrentDesc = system.ID
} else {
s.CurrentDesc = md.Name
}
Expand Down Expand Up @@ -209,8 +209,8 @@ func HandleMediaSearch(env requests.RequestEnv) (any, error) {

results = append(results, models.SearchResultMedia{
System: models.System{
Id: system.Id,
Name: system.Id,
Id: system.ID,
Name: system.ID,
},
Name: result.Name,
Path: env.Platform.NormalizePath(env.Config, result.Path),
Expand Down Expand Up @@ -283,13 +283,13 @@ func HandleUpdateActiveMedia(env requests.RequestEnv) (any, error) {
return nil, fmt.Errorf("error looking up system: %w", err)
}

systemMeta, err := assets.GetSystemMetadata(system.Id)
systemMeta, err := assets.GetSystemMetadata(system.ID)
if err != nil {
return nil, fmt.Errorf("error getting system metadata: %w", err)
}

activeMedia := models.ActiveMedia{
SystemId: system.Id,
SystemId: system.ID,
SystemName: systemMeta.Name,
MediaName: params.MediaName,
MediaPath: env.Platform.NormalizePath(env.Config, params.MediaPath),
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/methods/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,13 @@ func InstallRunMedia(

var launchers []platforms.Launcher
for _, l := range pl.Launchers() {
if l.SystemId == system.Id {
if l.SystemID == system.ID {
launchers = append(launchers, l)
}
}

if len(launchers) == 0 {
return "", fmt.Errorf("no launchers for system: %s", system.Id)
return "", fmt.Errorf("no launchers for system: %s", system.ID)
}

// just use the first launcher for now
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/methods/systems.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func HandleSystems(env requests.RequestEnv) (any, error) {
}

sr := models.System{
Id: system.Id,
Id: system.ID,
}

sm, err := assets.GetSystemMetadata(id)
Expand Down
7 changes: 7 additions & 0 deletions pkg/assets/systems/MSU1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"id": "MSU1",
"name": "SNES MSU-1",
"category": "Console",
"releaseDate": "2012-05-25",
"manufacturer": "Nintendo"
}
2 changes: 1 addition & 1 deletion pkg/configui/configui.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ func BuildScanModeMenu(cfg *config.Instance, pages *tview.Pages, app *tview.Appl

allSystems := []string{""}
for _, item := range systemdefs.AllSystems() {
allSystems = append(allSystems, item.Id)
allSystems = append(allSystems, item.ID)
}

exitDelay := cfg.ReadersScan().ExitDelay
Expand Down
36 changes: 18 additions & 18 deletions pkg/database/gamesdb/gamesdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func NewNamesIndex(

filteredIds := make([]string, 0)
for _, s := range systems {
filteredIds = append(filteredIds, s.Id)
filteredIds = append(filteredIds, s.ID)
}

indexed, err := readIndexedSystems(db)
Expand All @@ -221,13 +221,13 @@ func NewNamesIndex(
update(status)
systemPaths := make(map[string][]string)
for _, v := range GetSystemPaths(platform, platform.RootDirs(cfg), systems) {
systemPaths[v.System.Id] = append(systemPaths[v.System.Id], v.Path)
systemPaths[v.System.ID] = append(systemPaths[v.System.ID], v.Path)
}

g := new(errgroup.Group)
scanned := make(map[string]bool)
for _, s := range systemdefs.AllSystems() {
scanned[s.Id] = false
scanned[s.ID] = false
}

sysPathIds := utils.AlphaMapKeys(systemPaths)
Expand Down Expand Up @@ -257,7 +257,7 @@ func NewNamesIndex(
// for each system launcher in platform, run the results through its
// custom scan function if one exists
for _, l := range platform.Launchers() {
if l.SystemId == k && l.Scanner != nil {
if l.SystemID == k && l.Scanner != nil {
log.Debug().Msgf("running %s scanner for system: %s", l.Id, systemId)
files, err = l.Scanner(cfg, systemId, files)
if err != nil {
Expand Down Expand Up @@ -288,7 +288,7 @@ func NewNamesIndex(
// run each custom scanner at least once, even if there are no paths
// defined or results from regular index
for _, l := range platform.Launchers() {
systemId := l.SystemId
systemId := l.SystemID
if !scanned[systemId] && l.Scanner != nil {
log.Debug().Msgf("running %s scanner for system: %s", l.Id, systemId)
results, err := l.Scanner(cfg, systemId, []platforms.ScanResult{})
Expand Down Expand Up @@ -318,27 +318,27 @@ func NewNamesIndex(
// launcher scanners with no system defined are run against every system
var anyScanners []platforms.Launcher
for _, l := range platform.Launchers() {
if l.SystemId == "" && l.Scanner != nil {
if l.SystemID == "" && l.Scanner != nil {
anyScanners = append(anyScanners, l)
}
}

for _, l := range anyScanners {
for _, s := range systems {
log.Debug().Msgf("running %s scanner for system: %s", l.Id, s.Id)
results, err := l.Scanner(cfg, s.Id, []platforms.ScanResult{})
log.Debug().Msgf("running %s scanner for system: %s", l.Id, s.ID)
results, err := l.Scanner(cfg, s.ID, []platforms.ScanResult{})
if err != nil {
log.Error().Err(err).Msgf("error running %s scanner for system: %s", l.Id, s.Id)
log.Error().Err(err).Msgf("error running %s scanner for system: %s", l.Id, s.ID)
continue
}

log.Debug().Msgf("scanned %d files for system: %s", len(results), s.Id)
log.Debug().Msgf("scanned %d files for system: %s", len(results), s.ID)

if len(results) > 0 {
status.Files += len(results)
scanned[s.Id] = true
scanned[s.ID] = true

systemId := s.Id
systemId := s.ID
g.Go(func() error {
fis := make([]fileInfo, 0)
for _, p := range results {
Expand Down Expand Up @@ -416,7 +416,7 @@ func searchNamesGeneric(
bn := tx.Bucket([]byte(BucketNames))

for _, system := range systems {
pre := []byte(system.Id + ":")
pre := []byte(system.ID + ":")
nameIdx := bytes.Index(pre, []byte(":"))

c := bn.Cursor()
Expand All @@ -425,7 +425,7 @@ func searchNamesGeneric(

if test(query, keyName) {
results = append(results, SearchResult{
SystemId: system.Id,
SystemId: system.ID,
Name: keyName,
Path: string(v),
})
Expand Down Expand Up @@ -535,7 +535,7 @@ func SystemIndexed(platform platforms.Platform, system systemdefs.System) bool {
return false
}

return utils.Contains(systems, system.Id)
return utils.Contains(systems, system.ID)
}

// Return all systems indexed in the gamesdb
Expand Down Expand Up @@ -592,14 +592,14 @@ func RandomGame(platform platforms.Platform, systems []systemdefs.System) (Searc
err = db.View(func(tx *bolt.Tx) error {
bn := tx.Bucket([]byte(BucketNames))

pre := []byte(system.Id + ":")
pre := []byte(system.ID + ":")
nameIdx := bytes.Index(pre, []byte(":"))

c := bn.Cursor()
for k, v := c.Seek(pre); k != nil && bytes.HasPrefix(k, pre); k, v = c.Next() {
keyName := string(k[nameIdx+1:])
possible = append(possible, SearchResult{
SystemId: system.Id,
SystemId: system.ID,
Name: keyName,
Path: string(v),
})
Expand All @@ -612,7 +612,7 @@ func RandomGame(platform platforms.Platform, systems []systemdefs.System) (Searc
}

if len(possible) == 0 {
return result, fmt.Errorf("no games found for system: %s", system.Id)
return result, fmt.Errorf("no games found for system: %s", system.ID)
}

result, err = utils.RandomElem(possible)
Expand Down
6 changes: 3 additions & 3 deletions pkg/database/gamesdb/indexing.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func GetSystemPaths(pl platforms.Platform, rootFolders []string, systems []syste
for _, system := range systems {
var launchers []platforms.Launcher
for _, l := range pl.Launchers() {
if l.SystemId == system.Id {
if l.SystemID == system.ID {
launchers = append(launchers, l)
}
}
Expand Down Expand Up @@ -200,13 +200,13 @@ func GetFiles(

for i := range zipFiles {
abs := filepath.Join(path, zipFiles[i])
if utils.MatchSystemFile(cfg, platform, (*system).Id, abs) {
if utils.MatchSystemFile(cfg, platform, (*system).ID, abs) {
*results = append(*results, abs)
}
}
} else {
// regular files
if utils.MatchSystemFile(cfg, platform, (*system).Id, path) {
if utils.MatchSystemFile(cfg, platform, (*system).ID, path) {
*results = append(*results, path)
}
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/database/mappings.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func mappingKey(id string) []byte {
return []byte(fmt.Sprintf("mappings:%s", id))
}

func NormalizeUid(uid string) string {
func NormalizeID(uid string) string {
uid = strings.TrimSpace(uid)
uid = strings.ToLower(uid)
uid = strings.ReplaceAll(uid, ":", "")
Expand All @@ -66,7 +66,7 @@ func (d *Database) AddMapping(m Mapping) error {
}

if m.Type == MappingTypeUID {< 7A00 /td>
m.Pattern = NormalizeUid(m.Pattern)
m.Pattern = NormalizeID(m.Pattern)
}

if m.Pattern == "" {
Expand Down Expand Up @@ -128,7 +128,7 @@ func (d *Database) UpdateMapping(id string, m Mapping) error {
}

if m.Type == MappingTypeUID {
m.Pattern = NormalizeUid(m.Pattern)
m.Pattern = NormalizeID(m.Pattern)
}

if m.Pattern == "" {
Expand Down
Loading
0