VirtualBox

Ignore:
Timestamp:
Jul 23, 2018 3:35:51 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
123942
Message:

FE/Qt: bugref:9152: Export Appliance wizard: Make sure proper path is given to CAppliance:Write on exporting to cloud.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportApp.cpp

    r73146 r73333  
    5959bool UIWizardExportApp::exportAppliance()
    6060{
    61     /* We need to know every filename which will be created, so that we can ask the user for confirmation of overwriting.
    62      * For that we iterating over all virtual systems & fetch all descriptions of the type HardDiskImage. Also add the
    63      * manifest file to the check. In the .ova case only the target file itself get checked. */
    64 
    6561    /* Get export appliance widget & fetch all settings from the appliance editor: */
    6662    UIApplianceExportEditorWidget *pExportApplianceWidget = field("applianceWidget").value<ExportAppliancePointer>();
     
    6864    pExportApplianceWidget->prepareExport();
    6965
    70     /* Get the appliance: */
     66    /* Acquire the appliance: */
    7167    CAppliance *pComAppliance = pExportApplianceWidget->appliance();
    7268    AssertPtrReturn(pComAppliance, false);
    7369
    74     /* Compose a list of all required files: */
    75     QFileInfo fi(field("path").toString());
    76     QVector<QString> files;
    77 
    78     /* Add arhive itself: */
    79     files << fi.fileName();
    80 
    81     /* If archive is of .ovf type: */
    82     if (fi.suffix().toLower() == "ovf")
    83     {
    84         /* Add manifest file if requested: */
    85         if (field("manifestSelected").toBool())
    86             files << fi.baseName() + ".mf";
    87 
    88         /* Add all hard disk images: */
    89         CVirtualSystemDescriptionVector vsds = pComAppliance->GetVirtualSystemDescriptions();
    90         for (int i = 0; i < vsds.size(); ++i)
    91         {
    92             QVector<KVirtualSystemDescriptionType> types;
    93             QVector<QString> refs, origValues, configValues, extraConfigValues;
    94             vsds[i].GetDescriptionByType(KVirtualSystemDescriptionType_HardDiskImage, types,
    95                                          refs, origValues, configValues, extraConfigValues);
    96             foreach (const QString &strValue, origValues)
    97                 files << QString("%2").arg(strValue);
    98         }
    99     }
    100 
    101     /* Initialize VFS explorer: */
    102     CVFSExplorer comExplorer = pComAppliance->CreateVFSExplorer(uri(false /* fWithFile */));
    103     if (comExplorer.isNotNull())
    104     {
    105         CProgress comProgress = comExplorer.Update();
    106         if (comExplorer.isOk() && comProgress.isNotNull())
    107         {
    108             msgCenter().showModalProgressDialog(comProgress, QApplication::translate("UIWizardExportApp", "Checking files ..."),
    109                                                 ":/progress_refresh_90px.png", this);
    110             if (comProgress.GetCanceled())
    111                 return false;
    112             if (!comProgress.isOk() || comProgress.GetResultCode() != 0)
    113                 return msgCenter().cannotCheckFiles(comProgress, this);
     70    /* For Filesystem formats only: */
     71    if (field("format").toString() != "csp-1.0")
     72    {
     73        /* We need to know every filename which will be created, so that we can ask the user for confirmation of overwriting.
     74         * For that we iterating over all virtual systems & fetch all descriptions of the type HardDiskImage. Also add the
     75         * manifest file to the check. In the .ova case only the target file itself get checked. */
     76
     77        /* Compose a list of all required files: */
     78        QFileInfo fi(field("path").toString());
     79        QVector<QString> files;
     80
     81        /* Add arhive itself: */
     82        files << fi.fileName();
     83
     84        /* If archive is of .ovf type: */
     85        if (fi.suffix().toLower() == "ovf")
     86        {
     87            /* Add manifest file if requested: */
     88            if (field("manifestSelected").toBool())
     89                files << fi.baseName() + ".mf";
     90
     91            /* Add all hard disk images: */
     92            CVirtualSystemDescriptionVector vsds = pComAppliance->GetVirtualSystemDescriptions();
     93            for (int i = 0; i < vsds.size(); ++i)
     94            {
     95                QVector<KVirtualSystemDescriptionType> types;
     96                QVector<QString> refs, origValues, configValues, extraConfigValues;
     97                vsds[i].GetDescriptionByType(KVirtualSystemDescriptionType_HardDiskImage, types,
     98                                             refs, origValues, configValues, extraConfigValues);
     99                foreach (const QString &strValue, origValues)
     100                    files << QString("%2").arg(strValue);
     101            }
     102        }
     103
     104        /* Initialize VFS explorer: */
     105        CVFSExplorer comExplorer = pComAppliance->CreateVFSExplorer(uri(false /* fWithFile */));
     106        if (comExplorer.isNotNull())
     107        {
     108            CProgress comProgress = comExplorer.Update();
     109            if (comExplorer.isOk() && comProgress.isNotNull())
     110            {
     111                msgCenter().showModalProgressDialog(comProgress, QApplication::translate("UIWizardExportApp", "Checking files ..."),
     112                                                    ":/progress_refresh_90px.png", this);
     113                if (comProgress.GetCanceled())
     114                    return false;
     115                if (!comProgress.isOk() || comProgress.GetResultCode() != 0)
     116                    return msgCenter().cannotCheckFiles(comProgress, this);
     117            }
     118            else
     119                return msgCenter().cannotCheckFiles(comExplorer, this);
    114120        }
    115121        else
    116             return msgCenter().cannotCheckFiles(comExplorer, this);
    117     }
    118     else
    119         return msgCenter().cannotCheckFiles(*pComAppliance, this);
    120 
    121     /* Confirm overwriting for existing files: */
    122     QVector<QString> exists = comExplorer.Exists(files);
    123     if (!msgCenter().confirmOverridingFiles(exists, this))
    124         return false;
    125 
    126     /* DELETE all the files which exists after everything is confirmed: */
    127     if (!exists.isEmpty())
    128     {
    129         CProgress comProgress = comExplorer.Remove(exists);
    130         if (comExplorer.isOk() && comProgress.isNotNull())
    131         {
    132             msgCenter().showModalProgressDialog(comProgress, QApplication::translate("UIWizardExportApp", "Removing files ..."),
    133                                                 ":/progress_delete_90px.png", this);
    134             if (comProgress.GetCanceled())
    135                 return false;
    136             if (!comProgress.isOk() || comProgress.GetResultCode() != 0)
    137                 return msgCenter().cannotRemoveFiles(comProgress, this);
    138         }
    139         else
    140             return msgCenter().cannotCheckFiles(comExplorer, this);
     122            return msgCenter().cannotCheckFiles(*pComAppliance, this);
     123
     124        /* Confirm overwriting for existing files: */
     125        QVector<QString> exists = comExplorer.Exists(files);
     126        if (!msgCenter().confirmOverridingFiles(exists, this))
     127            return false;
     128
     129        /* DELETE all the files which exists after everything is confirmed: */
     130        if (!exists.isEmpty())
     131        {
     132            CProgress comProgress = comExplorer.Remove(exists);
     133            if (comExplorer.isOk() && comProgress.isNotNull())
     134            {
     135                msgCenter().showModalProgressDialog(comProgress, QApplication::translate("UIWizardExportApp", "Removing files ..."),
     136                                                    ":/progress_delete_90px.png", this);
     137                if (comProgress.GetCanceled())
     138                    return false;
     139                if (!comProgress.isOk() || comProgress.GetResultCode() != 0)
     140                    return msgCenter().cannotRemoveFiles(comProgress, this);
     141            }
     142            else
     143                return msgCenter().cannotCheckFiles(comExplorer, this);
     144        }
    141145    }
    142146
     
    147151QString UIWizardExportApp::uri(bool fWithFile) const
    148152{
    149     /* Prepare storage path: */
    150     QString strPath = field("path").toString();
    151     /* Append file name if requested: */
    152     if (!fWithFile)
    153     {
    154         QFileInfo fi(strPath);
    155         strPath = fi.path();
    156     }
    157 
    158     /* For known storage types: */
    159     StorageType enmType = field("storageType").value<StorageType>();
    160     switch (enmType)
    161     {
    162         case LocalFilesystem:
    163         {
    164             return strPath;
    165         }
    166         case CloudProvider:
    167         {
    168             const QString strUri("OCI://");
    169             return QString("%1%2").arg(strUri).arg(strPath);
    170         }
    171     }
    172 
    173     /* Nothing by default: */
    174     return QString();
     153    /* For Cloud Service Providers: */
     154    if (field("format").toString() == "csp-1.0")
     155        return QString("OCI://%1").arg(field("profile").toString());
     156    else
     157    {
     158        /* Prepare storage path: */
     159        QString strPath = field("path").toString();
     160        /* Append file name if requested: */
     161        if (!fWithFile)
     162        {
     163            QFileInfo fi(strPath);
     164            strPath = fi.path();
     165        }
     166
     167        /* Just path by default: */
     168        return strPath;
     169    }
    175170}
    176171
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette