4dde2c59 by astaxie

fix the parser.go lastupdate

1 parent 62e9c890
Showing 1 changed file with 17 additions and 4 deletions
...@@ -165,12 +165,12 @@ func compareFile(pkgRealpath string) bool { ...@@ -165,12 +165,12 @@ func compareFile(pkgRealpath string) bool {
165 return true 165 return true
166 } 166 }
167 json.Unmarshal(content, &pkgLastupdate) 167 json.Unmarshal(content, &pkgLastupdate)
168 ft, err := os.Lstat(pkgRealpath) 168 lastupdate, err := getpathTime(pkgRealpath)
169 if err != nil { 169 if err != nil {
170 return true 170 return true
171 } 171 }
172 if v, ok := pkgLastupdate[pkgRealpath]; ok { 172 if v, ok := pkgLastupdate[pkgRealpath]; ok {
173 if ft.ModTime().UnixNano() <= v { 173 if lastupdate <= v {
174 return false 174 return false
175 } 175 }
176 } 176 }
...@@ -179,14 +179,27 @@ func compareFile(pkgRealpath string) bool { ...@@ -179,14 +179,27 @@ func compareFile(pkgRealpath string) bool {
179 } 179 }
180 180
181 func savetoFile(pkgRealpath string) { 181 func savetoFile(pkgRealpath string) {
182 ft, err := os.Lstat(pkgRealpath) 182 lastupdate, err := getpathTime(pkgRealpath)
183 if err != nil { 183 if err != nil {
184 return 184 return
185 } 185 }
186 pkgLastupdate[pkgRealpath] = ft.ModTime().UnixNano() 186 pkgLastupdate[pkgRealpath] = lastupdate
187 d, err := json.Marshal(pkgLastupdate) 187 d, err := json.Marshal(pkgLastupdate)
188 if err != nil { 188 if err != nil {
189 return 189 return
190 } 190 }
191 ioutil.WriteFile(path.Join(AppPath, lastupdateFilename), d, os.ModePerm) 191 ioutil.WriteFile(path.Join(AppPath, lastupdateFilename), d, os.ModePerm)
192 } 192 }
193
194 func getpathTime(pkgRealpath string) (lastupdate int64, err error) {
195 fl, err := ioutil.ReadDir(pkgRealpath)
196 if err != nil {
197 return lastupdate, err
198 }
199 for _, f := range fl {
200 if lastupdate < f.ModTime().UnixNano() {
201 lastupdate = f.ModTime().UnixNano()
202 }
203 }
204 return lastupdate, nil
205 }
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!