LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2012, 2013 Canonical Ltd. | 1 // Copyright 2012, 2013 Canonical Ltd. |
2 // Licensed under the AGPLv3, see LICENCE file for details. | 2 // Licensed under the AGPLv3, see LICENCE file for details. |
3 | 3 |
4 package charm | 4 package charm |
5 | 5 |
6 import ( | 6 import ( |
7 "crypto/sha256" | 7 "crypto/sha256" |
8 "encoding/hex" | 8 "encoding/hex" |
9 "encoding/json" | 9 "encoding/json" |
10 "fmt" | 10 "fmt" |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 if !info.IsDir() { | 319 if !info.IsDir() { |
320 return nil, repoNotFound(r.Path) | 320 return nil, repoNotFound(r.Path) |
321 } | 321 } |
322 path := filepath.Join(r.Path, curl.Series) | 322 path := filepath.Join(r.Path, curl.Series) |
323 infos, err := ioutil.ReadDir(path) | 323 infos, err := ioutil.ReadDir(path) |
324 if err != nil { | 324 if err != nil { |
325 return nil, charmNotFound(curl, r.Path) | 325 return nil, charmNotFound(curl, r.Path) |
326 } | 326 } |
327 var latest Charm | 327 var latest Charm |
328 for _, info := range infos { | 328 for _, info := range infos { |
| 329 chPath := filepath.Join(path, info.Name()) |
| 330 if info.Mode()&os.ModeSymlink != 0 { |
| 331 var err error |
| 332 if info, err = os.Stat(chPath); err != nil { |
| 333 return nil, err |
| 334 } |
| 335 } |
329 if !mightBeCharm(info) { | 336 if !mightBeCharm(info) { |
330 continue | 337 continue |
331 } | 338 } |
332 chPath := filepath.Join(path, info.Name()) | |
333 if ch, err := Read(chPath); err != nil { | 339 if ch, err := Read(chPath); err != nil { |
334 log.Warningf("charm: failed to load charm at %q: %s", ch
Path, err) | 340 log.Warningf("charm: failed to load charm at %q: %s", ch
Path, err) |
335 } else if ch.Meta().Name == curl.Name { | 341 } else if ch.Meta().Name == curl.Name { |
336 if ch.Revision() == curl.Revision { | 342 if ch.Revision() == curl.Revision { |
337 return ch, nil | 343 return ch, nil |
338 } | 344 } |
339 if latest == nil || ch.Revision() > latest.Revision() { | 345 if latest == nil || ch.Revision() > latest.Revision() { |
340 latest = ch | 346 latest = ch |
341 } | 347 } |
342 } | 348 } |
343 } | 349 } |
344 if curl.Revision == -1 && latest != nil { | 350 if curl.Revision == -1 && latest != nil { |
345 return latest, nil | 351 return latest, nil |
346 } | 352 } |
347 return nil, charmNotFound(curl, r.Path) | 353 return nil, charmNotFound(curl, r.Path) |
348 } | 354 } |
LEFT | RIGHT |