skip loading if file doesn't exist

This commit is contained in:
piotr
2021-09-28 03:04:39 +02:00
parent 875c8078d6
commit 8c0d158e3d
2 changed files with 16 additions and 8 deletions

Binary file not shown.

View File

@@ -263,21 +263,29 @@ func main() {
// For opening files we use xdg-open. As its configuration is PITA, we may override some associations // For opening files we use xdg-open. As its configuration is PITA, we may override some associations
// in the ~/.config/nwg-panel/preferred-apps.json file. // in the ~/.config/nwg-panel/preferred-apps.json file.
paFile := path.Join(configDirectory, "preferred-apps.json") paFile := path.Join(configDirectory, "preferred-apps.json")
if pathExists(paFile) {
preferredApps, err = loadPreferredApps(paFile) preferredApps, err = loadPreferredApps(paFile)
if err != nil { if err != nil {
log.Infof("Custom associations file %s not found or invalid", paFile) log.Infof("Custom associations file %s not found or invalid", paFile)
} else { } else {
log.Infof("Found %v associations in %s", len(preferredApps), paFile) log.Infof("Found %v associations in %s", len(preferredApps), paFile)
} }
} else {
log.Infof("%s file not found", paFile)
}
// Load user-defined paths excluded from file search // Load user-defined paths excluded from file search
exFile := path.Join(configDirectory, "excluded-dirs") exFile := path.Join(configDirectory, "excluded-dirs")
if pathExists(exFile) {
exclusions, err = loadTextFile(exFile) exclusions, err = loadTextFile(exFile)
if err != nil { if err != nil {
log.Infof("Search exclusions file %s not found %s", exFile, err) log.Infof("Search exclusions file %s not found %s", exFile, err)
} else { } else {
log.Infof("Found %v search exclusions in %s", len(exclusions), exFile) log.Infof("Found %v search exclusions in %s", len(exclusions), exFile)
} }
} else {
log.Infof("%s file not found", exFile)
}
// USER INTERFACE // USER INTERFACE
gtk.Init(nil) gtk.Init(nil)