Changeset 31676 in vbox for trunk/src/VBox/Main/ApplianceImpl.cpp
- Timestamp:
- Aug 13, 2010 6:40:53 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ApplianceImpl.cpp
r31562 r31676 667 667 BOOL fCanceled; 668 668 ULONG currentPercent; 669 ULONG cOp = 0; 669 670 while (SUCCEEDED(pProgressAsync->COMGETTER(Completed(&fCompleted)))) 670 671 { … … 676 677 break; 677 678 } 678 679 rc = pProgressAsync->COMGETTER(Percent(¤tPercent)); 679 /* Check if the current operation have changed. It is also possible 680 that in the meantime more than one async operation was finished. So 681 we have to loop as long as we reached the same operation count. */ 682 ULONG curOp; 683 for(;;) 684 { 685 rc = pProgressAsync->COMGETTER(Operation(&curOp)); 686 if (FAILED(rc)) throw rc; 687 if (cOp != curOp) 688 { 689 Bstr bstr; 690 ULONG currentWeight; 691 rc = pProgressAsync->COMGETTER(OperationDescription(bstr.asOutParam())); 692 if (FAILED(rc)) throw rc; 693 rc = pProgressAsync->COMGETTER(OperationWeight(¤tWeight)); 694 if (FAILED(rc)) throw rc; 695 rc = pProgressThis->SetNextOperation(bstr, currentWeight); 696 if (FAILED(rc)) throw rc; 697 ++cOp; 698 }else 699 break; 700 } 701 702 rc = pProgressAsync->COMGETTER(OperationPercent(¤tPercent)); 680 703 if (FAILED(rc)) throw rc; 681 if (!pProgressThis.isNull()) 682 pProgressThis->SetCurrentOperationProgress(currentPercent); 704 pProgressThis->SetCurrentOperationProgress(currentPercent); 683 705 if (fCompleted) 684 706 break; … … 745 767 } 746 768 769 #include <iprt/tar.h> 747 770 /** 748 771 * Called from Appliance::importImpl() and Appliance::writeImpl() to set up a … … 754 777 * @return 755 778 */ 756 HRESULT Appliance::setUpProgress(ComObjPtr<Progress> &pProgress, 779 HRESULT Appliance::setUpProgress(const LocationInfo &locInfo, 780 ComObjPtr<Progress> &pProgress, 757 781 const Bstr &bstrDescription, 758 782 SetUpProgressMode mode) … … 785 809 } 786 810 811 bool fOVA = locInfo.strPath.endsWith(".ova", Utf8Str::CaseInsensitive); 787 812 switch (mode) 788 813 { 789 814 case ImportFileNoManifest: 790 break; 791 815 { 816 if (fOVA) 817 { 818 // Another operation for packing 819 ++cOperations; 820 821 // assume that packing the files into the archive has the same weight than creating all files in the ovf exporting step 822 ulTotalOperationsWeight += m->ulTotalDisksMB; 823 } 824 break; 825 } 792 826 case ImportFileWithManifest: 793 827 case WriteFile: 828 { 794 829 ++cOperations; // another one for creating the manifest 795 830 796 // assume that c hecking or creating the manifest will take 10% of the time it takes to export the disks831 // assume that creating the manifest will take 10% of the time it takes to export the disks 797 832 m->ulWeightForManifestOperation = m->ulTotalDisksMB / 10; 798 833 ulTotalOperationsWeight += m->ulWeightForManifestOperation; 799 break; 800 834 if (fOVA) 835 { 836 // Another operation for packing 837 ++cOperations; 838 839 // assume that packing the files into the archive has the same weight than creating all files in the ovf exporting step 840 ulTotalOperationsWeight += m->ulTotalDisksMB; 841 } 842 break; 843 } 801 844 case ImportS3: 802 845 { … … 814 857 ULONG ulInitWeight = (ULONG)((double)ulTotalOperationsWeight * 0.1 / 100); // use 0.1% for init 815 858 ulTotalOperationsWeight += ulInitWeight; 859 break; 816 860 } 817 break;818 819 861 case WriteS3: 820 862 { … … 834 876 ULONG ulOVFCreationWeight = (ULONG)((double)ulTotalOperationsWeight * 50.0 / 100.0); /* Use 50% for the creation of the OVF & the disks */ 835 877 ulTotalOperationsWeight += ulOVFCreationWeight; 878 break; 836 879 } 837 break;838 880 } 839 881 … … 916 958 } 917 959 918 Utf8Str Appliance::manifestFileName(Utf8Str aPath) const 919 { 960 Utf8Str Appliance::manifestFileName(const Utf8Str& aPath) const 961 { 962 Utf8Str strTmpPath = aPath; 920 963 /* Get the name part */ 921 char *pszMfName = RTStrDup(RTPathFilename( aPath.c_str()));964 char *pszMfName = RTStrDup(RTPathFilename(strTmpPath.c_str())); 922 965 /* Strip any extensions */ 923 966 RTPathStripExt(pszMfName); 924 967 /* Path without the filename */ 925 aPath.stripFilename();968 strTmpPath.stripFilename(); 926 969 /* Format the manifest path */ 927 Utf8StrFmt strMfFile("%s/%s.mf", aPath.c_str(), pszMfName);970 Utf8StrFmt strMfFile("%s/%s.mf", strTmpPath.c_str(), pszMfName); 928 971 RTStrFree(pszMfName); 929 972 return strMfFile; … … 973 1016 case TaskOVF::Read: 974 1017 if (task->locInfo.storageType == VFSType_File) 975 taskrc = pAppliance->readFS(task->locInfo );1018 taskrc = pAppliance->readFS(task->locInfo, task->pProgress); 976 1019 else if (task->locInfo.storageType == VFSType_S3) 977 1020 taskrc = pAppliance->readS3(task.get()); … … 980 1023 case TaskOVF::Import: 981 1024 if (task->locInfo.storageType == VFSType_File) 982 taskrc = pAppliance->importFS(task ->locInfo, task->pProgress);1025 taskrc = pAppliance->importFS(task.get()); 983 1026 else if (task->locInfo.storageType == VFSType_S3) 984 1027 taskrc = pAppliance->importS3(task.get()); … … 987 1030 case TaskOVF::Write: 988 1031 if (task->locInfo.storageType == VFSType_File) 989 taskrc = pAppliance->writeFS(task ->locInfo, task->enFormat, task->pProgress);1032 taskrc = pAppliance->writeFS(task.get()); 990 1033 else if (task->locInfo.storageType == VFSType_S3) 991 1034 taskrc = pAppliance->writeS3(task.get());
Note:
See TracChangeset
for help on using the changeset viewer.