VirtualBox

Changeset 38455 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Aug 15, 2011 9:57:51 AM (13 years ago)
Author:
vboxsync
Message:

Main-OVA: fix importing of renamed OVA files

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/ApplianceImpl.h

    r37862 r38455  
    150150    HRESULT readFSOVF(TaskOVF *pTask);
    151151    HRESULT readFSOVA(TaskOVF *pTask);
    152     HRESULT readFSImpl(TaskOVF *pTask, PVDINTERFACEIO pCallbacks, PSHA1STORAGE pStorage);
     152    HRESULT readFSImpl(TaskOVF *pTask, const RTCString &strFilename, PVDINTERFACEIO pCallbacks, PSHA1STORAGE pStorage);
    153153    HRESULT readS3(TaskOVF *pTask);
    154154
  • trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp

    r37862 r38455  
    841841            break;
    842842        }
    843         rc = readFSImpl(pTask, pSha1Callbacks, &storage);
     843
     844        rc = readFSImpl(pTask, pTask->locInfo.strPath, pSha1Callbacks, &storage);
    844845    }while(0);
    845846
     
    871872    PVDINTERFACEIO pSha1Callbacks = 0;
    872873    PVDINTERFACEIO pTarCallbacks = 0;
     874    char *pszFilename = 0;
    873875    do
    874876    {
     877        vrc = RTTarCurrentFile(tar, &pszFilename);
     878        if (RT_FAILURE(vrc))
     879        {
     880            rc = VBOX_E_FILE_ERROR;
     881            break;
     882        }
    875883        pSha1Callbacks = Sha1CreateInterface();
    876884        if (!pSha1Callbacks)
     
    896904            break;
    897905        }
    898         rc = readFSImpl(pTask, pSha1Callbacks, &storage);
     906        rc = readFSImpl(pTask, pszFilename, pSha1Callbacks, &storage);
    899907    }while(0);
    900908
     
    902910
    903911    /* Cleanup */
     912    if (pszFilename)
     913        RTMemFree(pszFilename);
    904914    if (pSha1Callbacks)
    905915        RTMemFree(pSha1Callbacks);
     
    913923}
    914924
    915 HRESULT Appliance::readFSImpl(TaskOVF *pTask, PVDINTERFACEIO pCallbacks, PSHA1STORAGE pStorage)
     925HRESULT Appliance::readFSImpl(TaskOVF *pTask, const RTCString &strFilename, PVDINTERFACEIO pCallbacks, PSHA1STORAGE pStorage)
    916926{
    917927    LogFlowFuncEnter();
     
    924934    try
    925935    {
    926         Utf8Str strOvfFile = Utf8Str(pTask->locInfo.strPath).stripExt().append(".ovf");
    927936        /* Read the OVF into a memory buffer */
    928937        size_t cbSize = 0;
    929         int vrc = Sha1ReadBuf(strOvfFile.c_str(), &pvTmpBuf, &cbSize, pCallbacks, pStorage);
     938        int vrc = Sha1ReadBuf(strFilename.c_str(), &pvTmpBuf, &cbSize, pCallbacks, pStorage);
    930939        if (   RT_FAILURE(vrc)
    931940            || !pvTmpBuf)
    932941            throw setError(VBOX_E_FILE_ERROR,
    933942                           tr("Could not read OVF file '%s' (%Rrc)"),
    934                            RTPathFilename(strOvfFile.c_str()), vrc);
     943                           RTPathFilename(strFilename.c_str()), vrc);
    935944        /* Copy the SHA1 sum of the OVF file for later validation */
    936945        m->strOVFSHA1Digest = pStorage->strDigest;
     
    13001309    PVDINTERFACEIO pSha1Callbacks = 0;
    13011310    PVDINTERFACEIO pTarCallbacks = 0;
     1311    char *pszFilename = 0;
    13021312    void *pvMfBuf = 0;
    13031313    writeLock.release();
     
    13221332                           tr("Internal error (%Rrc)"), vrc);
    13231333
     1334        /* Read the file name of the first file (need to be the ovf file). This
     1335         * is how all internal files are named. */
     1336        vrc = RTTarCurrentFile(tar, &pszFilename);
     1337        if (RT_FAILURE(vrc))
     1338            throw setError(E_FAIL,
     1339                           tr("Internal error (%Rrc)"), vrc);
    13241340        /* Skip the OVF file, cause this was read in IAppliance::Read already. */
    13251341        vrc = RTTarSeekNextFile(tar);
     
    13371353
    13381354        size_t cbMfSize = 0;
    1339         Utf8Str strMfFile = Utf8Str(pTask->locInfo.strPath).stripExt().append(".mf");
     1355        Utf8Str strMfFile = Utf8Str(pszFilename).stripExt().append(".mf");
    13401356        /* Create the import stack for the rollback on errors. */
    13411357        ImportStack stack(pTask->locInfo, m->pReader->m_mapDisks, pTask->pProgress);
     
    13661382        {
    13671383            /* Add the ovf file to the digest list. */
    1368             stack.llSrcDisksDigest.push_front(STRPAIR(Utf8Str(pTask->locInfo.strPath).stripExt().append(".ovf"), m->strOVFSHA1Digest));
     1384            stack.llSrcDisksDigest.push_front(STRPAIR(Utf8Str(pszFilename).stripExt().append(".ovf"), m->strOVFSHA1Digest));
    13691385            rc = verifyManifestFile(strMfFile, stack, pvMfBuf, cbMfSize);
    13701386            if (FAILED(rc)) throw rc;
     
    13801396
    13811397    /* Cleanup */
     1398    if (pszFilename)
     1399        RTMemFree(pszFilename);
    13821400    if (pvMfBuf)
    13831401        RTMemFree(pvMfBuf);
Note: See TracChangeset for help on using the changeset viewer.

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