@@ -228,7 +228,6 @@ func (c *cmdImageCopy) Run(cmd *cobra.Command, args []string) error {
228
228
229
229
// Copy the image
230
230
var imgInfo * api.Image
231
- var fp string
232
231
if conf .Remotes [remoteName ].Protocol != "incus" && ! c .flagCopyAliases && len (c .flagAliases ) == 0 {
233
232
// All image servers outside of other Incus servers are always public, so unless we
234
233
// need the aliases list too or the real fingerprint, we can skip the otherwise very expensive
@@ -243,22 +242,26 @@ func (c *cmdImageCopy) Run(cmd *cobra.Command, args []string) error {
243
242
if err != nil {
244
243
return err
245
244
}
246
-
247
- // Store the fingerprint for use when creating aliases later (as imgInfo.Fingerprint may be overridden)
248
- fp = imgInfo .Fingerprint
249
245
}
250
246
251
247
if imgInfo .Public && imgInfo .Fingerprint != name && ! strings .HasPrefix (imgInfo .Fingerprint , name ) {
252
248
// If dealing with an alias, set the imgInfo fingerprint to match the provided alias (needed for auto-update)
253
249
imgInfo .Fingerprint = name
254
250
}
255
251
252
+ aliases := make ([]api.ImageAlias , len (c .flagAliases ))
253
+ for i , entry := range c .flagAliases {
254
+ aliases [i ].Name = entry
255
+ }
256
+
256
257
copyArgs := incus.ImageCopyArgs {
257
- AutoUpdate : c .flagAutoUpdate ,
258
- Public : c .flagPublic ,
259
- Type : imageType ,
260
- Mode : c .flagMode ,
261
- Profiles : c .flagProfile ,
258
+ Aliases : aliases ,
259
+ AutoUpdate : c .flagAutoUpdate ,
260
+ CopyAliases : c .flagCopyAliases ,
261
+ Public : c .flagPublic ,
262
+ Type : imageType ,
263
+ Mode : c .flagMode ,
264
+ Profiles : c .flagProfile ,
262
265
}
263
266
264
267
// Do the copy
@@ -288,22 +291,6 @@ func (c *cmdImageCopy) Run(cmd *cobra.Command, args []string) error {
288
291
289
292
progress .Done (i18n .G ("Image copied successfully!" ))
290
293
291
- // Ensure aliases
292
- aliases := make ([]api.ImageAlias , len (c .flagAliases ))
293
- for i , entry := range c .flagAliases {
294
- aliases [i ].Name = entry
295
- }
296
-
297
- if c .flagCopyAliases {
298
- // Also add the original aliases
299
- aliases = append (aliases , imgInfo .Aliases ... )
300
- }
301
-
302
- err = ensureImageAliases (destinationServer , aliases , fp )
303
- if err != nil {
304
- return err
305
- }
306
-
307
294
return nil
308
295
}
309
296
0 commit comments