Changeset 25772

Show
Ignore:
Timestamp:
06/02/08 18:34:48 (6 months ago)
Author:
korli
Message:

better handles error and cancellation when copying

Location:
haiku/trunk/src/apps/installer
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • haiku/trunk/src/apps/installer/CopyEngine.cpp

    r25466 r25772  
    11/* 
    2  * Copyright 2005-2006, Jérôme DUVAL. All rights reserved. 
     2 * Copyright 2005-2008, Jérôme DUVAL. All rights reserved. 
    33 * Distributed under the terms of the MIT License. 
    44 */ 
     
    7777                        if (err != B_OK) { 
    7878                                ERR("Start failed"); 
     79                                SetStatusMessage("Installation aborted."); 
    7980                                BMessenger(fWindow).SendMessage(RESET_INSTALL); 
     81                        } else { 
     82                                BMessenger(fWindow).SendMessage(INSTALL_FINISHED); 
    8083                        } 
    8184                        break; 
     
    230233        BDirectory targetDir(targetDirectory.Path()); 
    231234        BDirectory srcDir(srcDirectory.Path()); 
    232         CopyFolder(srcDir, targetDir); 
     235        err = CopyFolder(srcDir, targetDir); 
     236 
     237        if (err != B_OK) 
     238                return err; 
    233239 
    234240        // copy selected packages 
     
    240246                for (int32 i = 0; i < count; i++) { 
    241247                        if (fControl->CheckUserCanceled()) 
    242                                 return B_OK; 
     248                                return B_CANCELED; 
    243249                        Package *p = static_cast<Package*>(fPackages->ItemAt(i)); 
    244250                        packageDir.SetTo(&srcDir, p->Folder()); 
    245                         CopyFolder(packageDir, targetDir); 
    246                 } 
    247         } 
    248  
    249         if (!fControl->CheckUserCanceled()) { 
    250                 LaunchFinishScript(targetDirectory); 
    251  
    252                 BMessage msg(INSTALL_FINISHED); 
    253                 BMessenger(fWindow).SendMessage(&msg); 
    254         } 
     251                        err = CopyFolder(packageDir, targetDir); 
     252                        if (err != B_OK) 
     253                                break; 
     254                } 
     255        } 
     256 
     257        if (err != B_OK) 
     258                return err; 
     259 
     260        if (fControl->CheckUserCanceled()) 
     261                return B_CANCELED; 
     262         
     263        LaunchFinishScript(targetDirectory); 
    255264 
    256265        return B_OK; 
     
    258267 
    259268 
    260 void 
     269status_t 
    261270CopyEngine::CopyFolder(BDirectory &srcDir, BDirectory &targetDir) 
    262271{ 
     
    284293                        entry.GetPath(&path); 
    285294                        ERR2("error while copying %s", path.Path()); 
    286                 } 
    287         } 
     295                        return err; 
     296                } 
     297        } 
     298 
     299        return B_OK; 
    288300} 
    289301 
  • haiku/trunk/src/apps/installer/CopyEngine.h

    r25466 r25772  
    3333                void LaunchInitScript(BPath &path); 
    3434                void LaunchFinishScript(BPath &path); 
    35                 void CopyFolder(BDirectory &srcDir, BDirectory &targetDir); 
     35                status_t CopyFolder(BDirectory &srcDir, BDirectory &targetDir); 
    3636 
    3737                InstallerWindow *fWindow; 
  • haiku/trunk/src/apps/installer/InstallerWindow.cpp

    r25466 r25772  
    11/* 
    2  * Copyright 2005, Jérôme DUVAL. All rights reserved. 
     2 * Copyright 2005-2008, Jérôme DUVAL. All rights reserved. 
    33 * Distributed under the terms of the MIT License. 
    44 */ 
     
    214214                                                fInstallStatus = kCancelled; 
    215215                                                SetStatusMessage("Installation cancelled."); 
    216                                                 PostMessage(RESET_INSTALL); 
    217216                                        } 
    218217                                        break; 
     
    264263                case INSTALL_FINISHED: 
    265264                        fBeginButton->SetLabel("Quit"); 
     265                        SetStatusMessage("Installation completed."); 
    266266                        fInstallStatus = kFinished; 
    267267                        DisableInterface(false);