2121#include  < multipass/exceptions/create_image_exception.h> 
2222#include  < multipass/exceptions/image_vault_exceptions.h> 
2323#include  < multipass/exceptions/unsupported_image_exception.h> 
24+ #include  < multipass/file_ops.h> 
2425#include  < multipass/json_utils.h> 
2526#include  < multipass/logging/log.h> 
2627#include  < multipass/platform.h> 
3031#include  < multipass/url_downloader.h> 
3132#include  < multipass/utils.h> 
3233#include  < multipass/vm_image.h> 
33- #include  < multipass/xz_image_decoder.h> 
3434
3535#include  < multipass/format.h> 
3636
@@ -170,7 +170,10 @@ void remove_source_images(const mp::VMImage& source_image, const mp::VMImage& pr
170170{
171171    //  The prepare phase may have been a no-op, check and only remove source images
172172    if  (source_image.image_path  != prepared_image.image_path )
173-         mp::vault::delete_file (source_image.image_path );
173+     {
174+         QFile source_file{source_image.image_path };
175+         MP_FILEOPS.remove (source_file);
176+     }
174177}
175178
176179void  delete_image_dir (const  mp::Path& image_path)
@@ -295,7 +298,7 @@ mp::VMImage mp::DefaultVMImageVault::fetch_image(const FetchType& fetch_type,
295298        }
296299
297300        vm_image = prepare (source_image);
298-         vm_image.id  = mp::vault::compute_image_hash (vm_image.image_path ).toStdString ();
301+         vm_image.id  = MP_IMAGE_VAULT_UTILS. compute_file_hash (vm_image.image_path ).toStdString ();
299302
300303        remove_source_images (source_image, vm_image);
301304
@@ -356,7 +359,8 @@ mp::VMImage mp::DefaultVMImageVault::fetch_image(const FetchType& fetch_type,
356359                                       last_modified.toString (),
357360                                       0 ,
358361                                       checksum.has_value ()};
359-                 const  auto  image_filename = mp::vault::filename_for (image_url.path ());
362+ 
363+                 const  auto  image_filename = QFileInfo{image_url.path ()}.fileName ();
360364                //  Attempt to make a sane directory name based on the filename of the image
361365
362366                const  auto  image_dir_name =
@@ -620,8 +624,10 @@ mp::VMImage mp::DefaultVMImageVault::download_and_prepare_source_image(
620624    }
621625    else 
622626    {
627+         QFileInfo file_info{info.image_location };
628+ 
623629        source_image.id  = id.toStdString ();
624-         source_image.image_path  = image_dir.filePath (mp::vault::filename_for (info. image_location ));
630+         source_image.image_path  = image_dir.filePath (file_info. fileName ( ));
625631        source_image.original_release  = info.release_title .toStdString ();
626632        source_image.release_date  = info.version .toStdString ();
627633
@@ -642,12 +648,12 @@ mp::VMImage mp::DefaultVMImageVault::download_and_prepare_source_image(
642648        {
643649            mpl::log (mpl::Level::debug, category, fmt::format (" Verifying hash \" {}\" " 
644650            monitor (LaunchProgress::VERIFY, -1 );
645-             mp::vault::verify_image_download (source_image.image_path , id);
651+             MP_IMAGE_VAULT_UTILS. verify_file_hash (source_image.image_path , id);
646652        }
647653
648654        if  (source_image.image_path .endsWith (" .xz" 
649655        {
650-             source_image.image_path  = mp::vault::extract_image (source_image.image_path , monitor, true );
656+             source_image.image_path  = MP_IMAGE_VAULT_UTILS. extract_file (source_image.image_path , monitor, true );
651657        }
652658
653659        auto  prepared_image = prepare (source_image);
@@ -674,14 +680,14 @@ QString mp::DefaultVMImageVault::extract_image_from(const VMImage& source_image,
674680    const  auto  image_name = file_info.fileName ().remove (" .xz" 
675681    const  auto  image_path = QDir (dest_dir).filePath (image_name);
676682
677-     return  mp::vault::extract_image (image_path, monitor);
683+     return  MP_IMAGE_VAULT_UTILS. extract_file (image_path, monitor);
678684}
679685
680686mp::VMImage mp::DefaultVMImageVault::image_instance_from (const  VMImage& prepared_image, const  mp::Path& dest_dir)
681687{
682688    MP_UTILS.make_dir (dest_dir);
683689
684-     return  {mp::vault::copy (prepared_image.image_path , dest_dir),
690+     return  {MP_IMAGE_VAULT_UTILS. copy_to_dir (prepared_image.image_path , dest_dir),
685691            prepared_image.id ,
686692            prepared_image.original_release ,
687693            prepared_image.current_release ,
0 commit comments