Skip to content

Commit b821d84

Browse files
committed
Closes #41
2 parents 24a9838 + 0f76794 commit b821d84

File tree

8 files changed

+102
-77
lines changed

8 files changed

+102
-77
lines changed

server/src/lib/utils.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@ import (
44
"image/jpeg"
55
"io"
66
"io/ioutil"
7-
"jbrodriguez/mediagui/server/src/dto"
7+
"log"
88
"net/http"
99
"os"
1010
"path/filepath"
1111

1212
"github.com/jbrodriguez/mlog"
1313
"github.com/jbrodriguez/pubsub"
1414
"github.com/nfnt/resize"
15+
16+
"jbrodriguez/mediagui/server/src/dto"
1517
)
1618

1719
// Exists - Check if File / Directory Exists
@@ -55,7 +57,7 @@ func RestGet(url string) (string, error) {
5557
if err != nil {
5658
return "", err
5759
}
58-
defer resp.Body.Close()
60+
defer Close(resp.Body)
5961

6062
// err = json.NewDecoder(resp.Body).Decode(reply)
6163
body, err := ioutil.ReadAll(resp.Body)
@@ -131,3 +133,11 @@ func ResizeImage(src, dst string) (err error) {
131133
// write new image to file
132134
return jpeg.Encode(out, m, nil)
133135
}
136+
137+
// Close -
138+
func Close(c io.Closer) {
139+
err := c.Close()
140+
if err != nil {
141+
log.Printf("ERROR: %s", err)
142+
}
143+
}

server/src/services/cache.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@ import (
44
"github.com/jbrodriguez/actor"
55
"github.com/jbrodriguez/mlog"
66
"github.com/jbrodriguez/pubsub"
7+
78
// "io/ioutil"
89
"fmt"
10+
"os"
11+
"path/filepath"
912
// "image/jpeg"
13+
1014
"jbrodriguez/mediagui/server/src/dto"
1115
"jbrodriguez/mediagui/server/src/lib"
1216
"jbrodriguez/mediagui/server/src/model"
13-
"os"
14-
"path/filepath"
1517
)
1618

1719
// Cache -

server/src/services/core.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import (
2121
"github.com/micro/go-micro/client"
2222
)
2323

24+
const cNotAvailable = "n/a"
25+
2426
// Core -
2527
type Core struct {
2628
bus *pubsub.PubSub
@@ -113,9 +115,9 @@ func (c *Core) addMovie(msg *pubsub.Message) {
113115

114116
// Since it's coming in through this endpoint, we know it's a stub
115117
movie.File_Title = movie.Title
116-
movie.Resolution = "n/a"
117-
movie.FileType = "n/a"
118-
movie.Location = "n/a"
118+
movie.Resolution = cNotAvailable
119+
movie.FileType = cNotAvailable
120+
movie.Location = cNotAvailable
119121
movie.Stub = 1
120122

121123
// 3 operations, rescrape, update and cache

0 commit comments

Comments
 (0)