1
0
mirror of https://github.com/garraflavatra/rolens.git synced 2025-01-18 13:07:58 +00:00

Changed os.ModePerm (777) file permissions to 644 and 755

This commit is contained in:
Romein van Buren 2023-12-22 16:00:54 +01:00
parent 773bcf65fd
commit 7687b094c8
Signed by: romein
GPG Key ID: 0EFF8478ADDF6C49
8 changed files with 11 additions and 14 deletions

View File

@ -14,6 +14,7 @@ Patches:
* Preserve state after switching to another tab (#56). * Preserve state after switching to another tab (#56).
* Find view: ask for confirmation before negligently deleting documents when the user has clicked the '-' button (#58). * Find view: ask for confirmation before negligently deleting documents when the user has clicked the '-' button (#58).
* Set a deadline for counting documents, and added a button to count documents if the deadline has been exceeded. * Set a deadline for counting documents, and added a button to count documents if the deadline has been exceeded.
* Changed os.ModePerm (777) file permissions to 644 and 755.
* UI improvements. * UI improvements.
Bugfixes: Bugfixes:

View File

@ -75,8 +75,8 @@ func NewApp(version string) *App {
panic(errors.New("unsupported platform")) panic(errors.New("unsupported platform"))
} }
os.MkdirAll(a.Env.DataDirectory, os.ModePerm) os.MkdirAll(a.Env.DataDirectory, 0755)
os.MkdirAll(a.Env.LogDirectory, os.ModePerm) os.MkdirAll(a.Env.LogDirectory, 0755)
return a return a
} }

View File

@ -3,7 +3,6 @@ package app
import ( import (
"encoding/json" "encoding/json"
"io/ioutil" "io/ioutil"
"os"
"path" "path"
"github.com/wailsapp/wails/v2/pkg/runtime" "github.com/wailsapp/wails/v2/pkg/runtime"
@ -77,7 +76,7 @@ func (a *App) UpdateSettings(jsonData string) Settings {
} }
filePath := path.Join(a.Env.DataDirectory, "settings.json") filePath := path.Join(a.Env.DataDirectory, "settings.json")
err = ioutil.WriteFile(filePath, newJson, os.ModePerm) err = ioutil.WriteFile(filePath, newJson, 0644)
if err != nil { if err != nil {
runtime.LogErrorf(a.ctx, "Could not update host list: %s", err.Error()) runtime.LogErrorf(a.ctx, "Could not update host list: %s", err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{

View File

@ -3,7 +3,6 @@ package app
import ( import (
"encoding/json" "encoding/json"
"io/ioutil" "io/ioutil"
"os"
"path" "path"
"github.com/wailsapp/wails/v2/pkg/runtime" "github.com/wailsapp/wails/v2/pkg/runtime"
@ -25,7 +24,7 @@ func updateQueryFile(a *App, newData map[string]SavedQuery) error {
return err return err
} }
err = ioutil.WriteFile(filePath, jsonData, os.ModePerm) err = ioutil.WriteFile(filePath, jsonData, 0644)
return err return err
} }

View File

@ -142,7 +142,7 @@ func (a *App) SaveShellScript(hostKey, dbKey, collKey, script string, temp bool)
scriptHeader = scriptHeader + "\n" scriptHeader = scriptHeader + "\n"
script = scriptHeader + strings.TrimLeft(strings.TrimRight(script, " \t\n"), "\n") script = scriptHeader + strings.TrimLeft(strings.TrimRight(script, " \t\n"), "\n")
if err := os.WriteFile(result.Fname, []byte(script), os.ModePerm); err != nil { if err := os.WriteFile(result.Fname, []byte(script), 0755); err != nil {
runtime.LogWarningf(a.ctx, "Shell: failed to write script to %s: %s", result.Fname, err.Error()) runtime.LogWarningf(a.ctx, "Shell: failed to write script to %s: %s", result.Fname, err.Error())
result.ErrorTitle = "Could not create temporary script file" result.ErrorTitle = "Could not create temporary script file"
result.ErrorDescription = err.Error() result.ErrorDescription = err.Error()
@ -154,7 +154,7 @@ func (a *App) SaveShellScript(hostKey, dbKey, collKey, script string, temp bool)
func (a *App) OpenShellScript() string { func (a *App) OpenShellScript() string {
dir := path.Join(a.Env.DataDirectory, "Shell Scripts") dir := path.Join(a.Env.DataDirectory, "Shell Scripts")
os.MkdirAll(dir, os.ModePerm) os.MkdirAll(dir, 0755)
fname, err := runtime.OpenFileDialog(a.ctx, runtime.OpenDialogOptions{ fname, err := runtime.OpenFileDialog(a.ctx, runtime.OpenDialogOptions{
DefaultDirectory: path.Join(a.Env.DataDirectory, "Shell Scripts"), DefaultDirectory: path.Join(a.Env.DataDirectory, "Shell Scripts"),
@ -200,7 +200,7 @@ func (a *App) SaveShellOuput(output string) {
}) })
} }
if err := os.WriteFile(fname, []byte(output), os.ModePerm); err != nil { if err := os.WriteFile(fname, []byte(output), 0755); err != nil {
runtime.LogWarningf(a.ctx, "Shell: error writing shell output to %s: %s", fname, err.Error()) runtime.LogWarningf(a.ctx, "Shell: error writing shell output to %s: %s", fname, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{
Title: "Error writing shell output", Title: "Error writing shell output",

View File

@ -4,7 +4,6 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"io/ioutil" "io/ioutil"
"os"
"path" "path"
"github.com/google/uuid" "github.com/google/uuid"
@ -23,7 +22,7 @@ func updateHostsFile(a *App, newData map[string]Host) error {
return err return err
} }
err = ioutil.WriteFile(filePath, jsonData, os.ModePerm) err = ioutil.WriteFile(filePath, jsonData, 0644)
return err return err
} }

View File

@ -4,7 +4,6 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"io/ioutil" "io/ioutil"
"os"
"path" "path"
"github.com/wailsapp/wails/v2/pkg/runtime" "github.com/wailsapp/wails/v2/pkg/runtime"
@ -63,7 +62,7 @@ func updateViewStore(a *App, newData ViewStore) error {
return err return err
} }
err = ioutil.WriteFile(filePath, jsonData, os.ModePerm) err = ioutil.WriteFile(filePath, jsonData, 0644)
return err return err
} }

View File

@ -21,7 +21,7 @@ func NewAppLogger(directory, filename string) *AppLogger {
} }
func (l *AppLogger) Print(message string) { func (l *AppLogger) Print(message string) {
os.MkdirAll(l.directory, os.ModePerm) os.MkdirAll(l.directory, 0755)
f, _ := os.OpenFile(l.filepath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) f, _ := os.OpenFile(l.filepath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
f.WriteString(message) f.WriteString(message)
f.Close() f.Close()