@@ -24,12 +24,11 @@ import (
2424)
2525
2626type HdaShare struct {
27- id int
28- Name string `json:"name"`
29- UpdatedAt time.Time `json:"updated_at"`
30- Path string `json:"path"`
31- Tags string `json:"tags"`
32- IsWritable bool `json:"is_writable"`
27+ name string
28+ updatedAt time.Time
29+ path string
30+ tags string
31+ isWritable bool
3332}
3433
3534type HdaShares struct {
@@ -72,8 +71,8 @@ func (shares *HdaShares) updateSqlShares() error {
7271 newShares := make ([]* HdaShare , 0 )
7372 for rows .Next () {
7473 share := new (HdaShare )
75- rows .Scan (& share .Name , & share .UpdatedAt , & share .Path , & share .Tags )
76- debug (5 , "share found: %s\n " , share .Name )
74+ rows .Scan (& share .name , & share .updatedAt , & share .path , & share .tags )
75+ debug (5 , "share found: %s\n " , share .name )
7776 newShares = append (newShares , share )
7877 }
7978
@@ -108,13 +107,12 @@ func (shares *HdaShares) updateDirShares() (nil error) {
108107 for i := range fis {
109108 if fis [i ].IsDir () && strings .Index (fis [i ].Name (), "." ) != 0 {
110109 share := new (HdaShare )
111- share .id = i
112- share .Name = fis [i ].Name ()
113- share .UpdatedAt = fis [i ].ModTime ()
114- share .Tags = fis [i ].Name ()
110+ share .name = fis [i ].Name ()
111+ share .updatedAt = fis [i ].ModTime ()
112+ share .tags = fis [i ].Name ()
115113 prefix , _ := filepath .Abs (shares .rootDir )
116- share .Path = prefix + "/" + fis [i ].Name ()
117- share .IsWritable = true
114+ share .path = prefix + "/" + fis [i ].Name ()
115+ share .isWritable = true
118116 newShares = append (newShares , share )
119117 }
120118 }
@@ -129,7 +127,7 @@ func (shares *HdaShares) updateDirShares() (nil error) {
129127
130128func (shares * HdaShares ) Get (shareName string ) * HdaShare {
131129 for i := range shares .Shares {
132- if shares .Shares [i ].Name == shareName {
130+ if shares .Shares [i ].name == shareName {
133131 return shares .Shares [i ]
134132 }
135133 }
@@ -146,10 +144,10 @@ func SharesJson(shares []*HdaShare) string {
146144 for i := range shares {
147145 temp := "{"
148146 // NB: 'name' and 'mtime' are used because of API spec
149- temp += fmt .Sprintf (`"name": "%s", ` , shares [i ].Name )
150- temp += fmt .Sprintf (`"mtime": "%s", ` , shares [i ].UpdatedAt .Format (http .TimeFormat ))
147+ temp += fmt .Sprintf (`"name": "%s", ` , shares [i ].name )
148+ temp += fmt .Sprintf (`"mtime": "%s", ` , shares [i ].updatedAt .Format (http .TimeFormat ))
151149 temp += fmt .Sprintf (`"tags": [%s],` , strings .Join (shares [i ].tagsList (), ", " ))
152- temp += fmt .Sprintf (`"is_writable": %t` , shares [i ].IsWritable )
150+ temp += fmt .Sprintf (`"is_writable": %t` , shares [i ].isWritable )
153151 temp += "}"
154152 ss = append (ss , temp )
155153 }
@@ -162,13 +160,13 @@ func SharesJson(shares []*HdaShare) string {
162160
163161// external interface to the path of a share
164162func (s * HdaShare ) GetPath () string {
165- return s .Path
163+ return s .path
166164}
167165
168166// return a list of tags, cleaned up
169167func (s * HdaShare ) tagsList () []string {
170168 re := regexp .MustCompile (`(\s*,+\s*)+` )
171- ta := re .Split (s .Tags , - 1 )
169+ ta := re .Split (s .tags , - 1 )
172170 r := make ([]string , 0 )
173171 for _ , tag := range ta {
174172 if tag != "" {
@@ -183,9 +181,9 @@ func (shares *HdaShares) startMetadataPrefill(library *metadata.Library) {
183181 // start it up after some time, to prevent overloads
184182 time .Sleep (15 * time .Second )
185183 for i := range shares .Shares {
186- path := shares .Shares [i ].Path
187- tags := strings .ToLower (shares .Shares [i ].Tags )
188- debug (5 , `checking share "%s" (%s) with tags: %s\n` , shares .Shares [i ].Name , path , tags )
184+ path := shares .Shares [i ].path
185+ tags := strings .ToLower (shares .Shares [i ].tags )
186+ debug (5 , `checking share "%s" (%s) with tags: %s\n` , shares .Shares [i ].name , path , tags )
189187 if path == "" || tags == "" {
190188 continue
191189 }
0 commit comments