Skip to content

Commit

Permalink
fix: fixed file permissions issue
Browse files Browse the repository at this point in the history
  • Loading branch information
karl-cardenas-coding committed Oct 16, 2020
1 parent 2df159a commit d7c19c9
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/categories.go
Expand Up @@ -58,7 +58,7 @@ The returned category may be used with the --filter flag for the event cmd.`,
}

if outputFlag == "json" {
json, err := json.MarshalIndent(records, "", "")
json, err := json.MarshalIndent(records, " ", " ")
if err != nil {
log.WithFields(log.Fields{
"package": "cmd",
Expand Down
4 changes: 2 additions & 2 deletions cmd/events.go
Expand Up @@ -74,7 +74,7 @@ func outputJSON(records library.EventResponse, filters []string) {

}

json, err := json.MarshalIndent(&list, "", "")
json, err := json.MarshalIndent(&list, " ", " ")
if err != nil {
log.WithFields(log.Fields{
"package": "cmd",
Expand All @@ -91,7 +91,7 @@ func outputJSON(records library.EventResponse, filters []string) {

if len(filters) == 0 {

json, err := json.MarshalIndent(&records, "", "")
json, err := json.MarshalIndent(&records, " ", " ")
if err != nil {
log.WithFields(log.Fields{
"package": "cmd",
Expand Down
26 changes: 25 additions & 1 deletion cmd/update.go
Expand Up @@ -296,6 +296,18 @@ func DownloadFile(filePath string, url string) error {
return err
}

if err := os.Chmod(tmpDir+pathOSeperator+"download.tmp", 0755); err != nil {
log.WithFields(log.Fields{
"package": "cmd",
"file": "update.go",
"parent_function": "DownloadFile",
"function": "os.Chmod",
"error": err,
"data": fmt.Sprint((tmpDir + pathOSeperator + "download.tmp")),
}).Error("Error changing permissions.", ISSUE_MSG)
return err
}

// Get the data
resp, err := http.Get(url)
if err != nil {
Expand Down Expand Up @@ -376,6 +388,18 @@ func DownloadFile(filePath string, url string) error {

}

if err := os.Chmod("disaster.tmp", 0755); err != nil {
log.WithFields(log.Fields{
"package": "cmd",
"file": "update.go",
"parent_function": "DownloadFile",
"function": "os.Chmod",
"error": err,
"data": "disaster.tmp",
}).Error("Error changing permissions.", ISSUE_MSG)
return err
}

// Loop through content of zip file
for _, f := range zipFile.File {

Expand Down Expand Up @@ -527,7 +551,7 @@ func userInput() (bool, error) {
case 'n':
output = false
default:
fmt.Println("Invalid entry! Please enter Y OR N")
fmt.Println("Invalid entry! Please enter Y/n")
}

if output {
Expand Down
Binary file added disaster
Binary file not shown.
3 changes: 3 additions & 0 deletions go.sum
Expand Up @@ -199,11 +199,13 @@ github.com/spf13/cobra v0.0.7 h1:FfTH+vuMXOas8jmfb5/M7dzEYx7LpcLb7a0LPe34uOU=
github.com/spf13/cobra v0.0.7/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
github.com/spf13/cobra v1.0.0 h1:6m/oheQuQ13N9ks4hubMG6BnvwOeaJrqSPLahSnczz8=
github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
github.com/spf13/cobra v1.1.0 h1:aq3wCKjTPmzcNWLVGnsFVN4rflK7Uzn10F8/aw8MhdQ=
github.com/spf13/cobra v1.1.0/go.mod h1:yk5b0mALVusDL5fMM6Rd1wgnoO5jUPhwsQ6LQAJTidQ=
github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/viper v1.4.0 h1:yXHLWeravcrgGyFSyCgdYpXQ9dR9c/WED3pg1RhxqEU=
github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE=
Expand Down Expand Up @@ -354,6 +356,7 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
Expand Down

0 comments on commit d7c19c9

Please sign in to comment.