VirtualBox

Changeset 78668 in vbox for trunk/src


Ignore:
Timestamp:
May 22, 2019 4:39:59 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9470: Networking stuff: Make sure particular network customers which download files check whether these files were already saved by RTHttp before trying to overwrite them.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/net
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/net/UIDownloaderAdditions.cpp

    r76606 r78668  
    147147    while (true)
    148148    {
    149         /* Try to open file for writing: */
     149        /* Make sure the file already exists.  If we reached
     150         * this place, it's already written and checked. */
    150151        QFile file(target());
    151         if (file.open(QIODevice::WriteOnly))
     152        bool fSuccess = false;
     153        /* Check step. Try to open file for reading first. */
     154        if (file.open(QIODevice::ReadOnly))
     155            fSuccess = true;
     156        /* Failsafe step. Try to open file for writing otherwise. */
     157        if (!fSuccess && file.open(QIODevice::WriteOnly))
    152158        {
    153159            /* Write buffer into the file: */
    154160            file.write(m_receivedData);
    155161            file.close();
    156 
     162            fSuccess = true;
     163        }
     164        /* If the file already exists or was just written: */
     165        if (fSuccess)
     166        {
    157167            /* Warn the user about additions-image loaded and saved, propose to mount it: */
    158168            if (msgCenter().proposeMountGuestAdditions(source().toString(), QDir::toNativeSeparators(target())))
  • trunk/src/VBox/Frontends/VirtualBox/src/net/UIDownloaderExtensionPack.cpp

    r76606 r78668  
    149149    while (true)
    150150    {
    151         /* Try to open file for writing: */
     151        /* Make sure the file already exists.  If we reached
     152         * this place, it's already written and checked. */
    152153        QFile file(target());
    153         if (file.open(QIODevice::WriteOnly))
     154        bool fSuccess = false;
     155        /* Check step. Try to open file for reading first. */
     156        if (file.open(QIODevice::ReadOnly))
     157            fSuccess = true;
     158        /* Failsafe step. Try to open file for writing otherwise. */
     159        if (!fSuccess && file.open(QIODevice::WriteOnly))
    154160        {
    155161            /* Write buffer into the file: */
    156162            file.write(m_receivedData);
    157163            file.close();
    158 
     164            fSuccess = true;
     165        }
     166        /* If the file already exists or was just written: */
     167        if (fSuccess)
     168        {
    159169            /* Warn the listener about extension-pack was downloaded: */
    160170            emit sigDownloadFinished(source().toString(), target(), strCalculatedSumm);
  • trunk/src/VBox/Frontends/VirtualBox/src/net/UIDownloaderUserManual.cpp

    r76606 r78668  
    9090    while (true)
    9191    {
    92         /* Try to open file for writing: */
     92        /* Make sure the file already exists.  If we reached
     93         * this place, it's already written and checked. */
    9394        QFile file(target());
    94         if (file.open(QIODevice::WriteOnly))
     95        bool fSuccess = false;
     96        /* Check step. Try to open file for reading first. */
     97        if (file.open(QIODevice::ReadOnly))
     98            fSuccess = true;
     99        /* Failsafe step. Try to open file for writing otherwise. */
     100        if (!fSuccess && file.open(QIODevice::WriteOnly))
    95101        {
    96102            /* Write buffer into the file: */
    97103            file.write(receivedData);
    98104            file.close();
    99 
     105            fSuccess = true;
     106        }
     107        /* If the file already exists or was just written: */
     108        if (fSuccess)
     109        {
    100110            /* Warn the user about user-manual loaded and saved: */
    101111            msgCenter().warnAboutUserManualDownloaded(source().toString(), QDir::toNativeSeparators(target()));
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