LEFT | RIGHT |
1 // Copyright 2013 Canonical Ltd. | 1 // Copyright 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 imagemetadata | 4 package imagemetadata |
5 | 5 |
6 import ( | 6 import ( |
7 "bytes" | 7 "bytes" |
8 "fmt" | 8 "fmt" |
9 "path/filepath" | 9 "path/filepath" |
10 "time" | 10 "time" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 var allCloudSpecs = []simplestreams.CloudSpec{*cloudSpec} | 66 var allCloudSpecs = []simplestreams.CloudSpec{*cloudSpec} |
67 for _, im := range existingMetadata { | 67 for _, im := range existingMetadata { |
68 if _, ok := imageIds[mapKey(im)]; ok { | 68 if _, ok := imageIds[mapKey(im)]; ok { |
69 continue | 69 continue |
70 } | 70 } |
71 toWrite = append(toWrite, im) | 71 toWrite = append(toWrite, im) |
72 if _, ok := regions[im.RegionName]; ok { | 72 if _, ok := regions[im.RegionName]; ok { |
73 continue | 73 continue |
74 } | 74 } |
75 regions[im.RegionName] = true | 75 regions[im.RegionName] = true |
76 » » existingCloudSpec := simplestreams.CloudSpec{Region: im.RegionNa
me, Endpoint: im.Endpoint} | 76 » » existingCloudSpec := simplestreams.CloudSpec{ |
| 77 » » » Region: im.RegionName, |
| 78 » » » Endpoint: im.Endpoint, |
| 79 » » } |
77 allCloudSpecs = append(allCloudSpecs, existingCloudSpec) | 80 allCloudSpecs = append(allCloudSpecs, existingCloudSpec) |
78 } | 81 } |
79 return toWrite, allCloudSpecs | 82 return toWrite, allCloudSpecs |
80 } | 83 } |
81 | 84 |
82 type MetadataFile struct { | 85 type MetadataFile struct { |
83 Path string | 86 Path string |
84 Data []byte | 87 Data []byte |
85 } | 88 } |
86 | 89 |
(...skipping 12 matching lines...) Expand all Loading... |
99 } | 102 } |
100 for _, md := range metadataInfo { | 103 for _, md := range metadataInfo { |
101 err = metadataStore.Put( | 104 err = metadataStore.Put( |
102 filepath.Join(storage.BaseImagesPath, md.Path), bytes.Ne
wReader(md.Data), int64(len(md.Data))) | 105 filepath.Join(storage.BaseImagesPath, md.Path), bytes.Ne
wReader(md.Data), int64(len(md.Data))) |
103 if err != nil { | 106 if err != nil { |
104 return err | 107 return err |
105 } | 108 } |
106 } | 109 } |
107 return nil | 110 return nil |
108 } | 111 } |
LEFT | RIGHT |