@@ -820,7 +820,6 @@ func getImgPostInfo(ctx context.Context, s *state.State, r *http.Request, buildd
820
820
}
821
821
822
822
var exists bool
823
-
824
823
err = s .DB .Cluster .Transaction (ctx , func (ctx context.Context , tx * db.ClusterTx ) error {
825
824
// Check if the image already exists
826
825
exists , err = tx .ImageExists (ctx , project , info .Fingerprint )
@@ -1017,7 +1016,6 @@ func imagesPost(d *Daemon, r *http.Request) response.Response {
1017
1016
fingerprint := r .Header .Get ("X-Incus-fingerprint" )
1018
1017
1019
1018
var imageMetadata map [string ]any
1020
-
1021
1019
if ! trusted && (secret == "" || fingerprint == "" ) {
1022
1020
return response .Forbidden (nil )
1023
1021
} else {
@@ -1193,9 +1191,18 @@ func imagesPost(d *Daemon, r *http.Request) response.Response {
1193
1191
}
1194
1192
1195
1193
// Apply any provided alias
1196
- aliases , ok := imageMetadata ["aliases" ]
1197
- if ok {
1198
- req .Aliases = aliases .([]api.ImageAlias )
1194
+ if len (req .Aliases ) == 0 {
1195
+ aliases , ok := imageMetadata ["aliases" ]
1196
+ if ok {
1197
+ // Used to get aliases from push mode image copy operation.
1198
+ aliases , ok := aliases .([]api.ImageAlias )
1199
+ if ok {
1200
+ req .Aliases = aliases
1201
+ }
1202
+ } else if len (info .Aliases ) > 0 {
1203
+ // Used to get aliases from HTTP headers on raw image imports.
1204
+ req .Aliases = info .Aliases
1205
+ }
1199
1206
}
1200
1207
1201
1208
err = s .DB .Cluster .Transaction (context .TODO (), func (ctx context.Context , tx * db.ClusterTx ) error {
0 commit comments