* Refactored the way targets are collected before copy process begins, this
way, the optional packages (if there would be any) can be collected as well before the actual process starts and the progress bar will reflect them correctly. Before this change, the progress bar would have reset itself for every optional package. * In one of my previous commits, I added the error, if there was any, to the reset message. Now the Installer window looks for the error and tells the user about it. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30602 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
f827b0168a
commit
92cd10f4db
@ -70,9 +70,8 @@ CopyEngine::~CopyEngine()
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
CopyEngine::CopyFolder(const char* source, const char* destination,
|
||||
BLocker* locker)
|
||||
void
|
||||
CopyEngine::ResetTargets()
|
||||
{
|
||||
fBytesRead = 0;
|
||||
fItemsCopied = 0;
|
||||
@ -87,10 +86,27 @@ CopyEngine::CopyFolder(const char* source, const char* destination,
|
||||
fCurrentTargetFolder = NULL;
|
||||
fCurrentItem = NULL;
|
||||
|
||||
if (fMessage) {
|
||||
BMessage message(*fMessage);
|
||||
message.AddString("status", "Collecting copy information.");
|
||||
fMessenger.SendMessage(&message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
CopyEngine::CollectTargets(const char* source)
|
||||
{
|
||||
int32 level = 0;
|
||||
status_t ret = _CollectCopyInfo(source, level);
|
||||
if (ret < B_OK)
|
||||
return ret;
|
||||
return _CollectCopyInfo(source, level);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
CopyEngine::CopyFolder(const char* source, const char* destination,
|
||||
BLocker* locker = NULL)
|
||||
{
|
||||
printf("%lld bytes to read in %lld files\n", fBytesToCopy, fItemsToCopy);
|
||||
|
||||
if (fMessage) {
|
||||
BMessage message(*fMessage);
|
||||
@ -98,9 +114,7 @@ CopyEngine::CopyFolder(const char* source, const char* destination,
|
||||
fMessenger.SendMessage(&message);
|
||||
}
|
||||
|
||||
printf("%lld bytes to read in %lld files\n", fBytesToCopy, fItemsToCopy);
|
||||
|
||||
level = 0;
|
||||
int32 level = 0;
|
||||
return _CopyFolder(source, destination, level, locker);
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,9 @@ public:
|
||||
BMessage* message);
|
||||
virtual ~CopyEngine();
|
||||
|
||||
void ResetTargets();
|
||||
status_t CollectTargets(const char* source);
|
||||
|
||||
status_t CopyFolder(const char* source,
|
||||
const char* destination,
|
||||
BLocker* locker = NULL);
|
||||
|
@ -359,9 +359,19 @@ InstallerWindow::MessageReceived(BMessage *msg)
|
||||
{
|
||||
switch (msg->what) {
|
||||
case MSG_RESET:
|
||||
{
|
||||
delete fCopyEngineLock;
|
||||
fCopyEngineLock = NULL;
|
||||
|
||||
status_t error;
|
||||
if (msg->FindInt32("error", &error) == B_OK) {
|
||||
char errorMessage[2048];
|
||||
snprintf(errorMessage, sizeof(errorMessage), "An error was "
|
||||
"encountered and the installation was not completed:\n\n"
|
||||
"Error: %s", strerror(error));
|
||||
(new BAlert("error", errorMessage, "Ok"))->Go();
|
||||
}
|
||||
|
||||
fInstallStatus = kReadyForInstall;
|
||||
fBeginButton->SetEnabled(true);
|
||||
_DisableInterface(false);
|
||||
@ -372,6 +382,7 @@ InstallerWindow::MessageReceived(BMessage *msg)
|
||||
|
||||
fBeginButton->SetLabel("Begin");
|
||||
break;
|
||||
}
|
||||
case START_SCAN:
|
||||
_ScanPartitions();
|
||||
break;
|
||||
@ -530,7 +541,7 @@ InstallerWindow::QuitRequested()
|
||||
if (fDriveSetupLaunched) {
|
||||
(new BAlert("driveSetup",
|
||||
"Please close the DriveSetup window before closing the "
|
||||
"Installer window.", "OK"))->Go();
|
||||
"Installer window.", "Ok"))->Go();
|
||||
return false;
|
||||
}
|
||||
_QuitCopyEngine(false);
|
||||
|
@ -388,6 +388,25 @@ WorkerThread::_PerformInstall(BMenu *srcMenu, BMenu *targetMenu)
|
||||
|
||||
_LaunchInitScript(targetDirectory);
|
||||
|
||||
// let the engine collect information for the progress bar later on
|
||||
engine.ResetTargets();
|
||||
err = engine.CollectTargets(srcDirectory.Path());
|
||||
if (err != B_OK)
|
||||
goto error;
|
||||
|
||||
// collect selected packages also
|
||||
if (fPackages) {
|
||||
BPath pkgRootDir(srcDirectory.Path(), PACKAGES_DIRECTORY);
|
||||
int32 count = fPackages->CountItems();
|
||||
for (int32 i = 0; i < count; i++) {
|
||||
Package *p = static_cast<Package*>(fPackages->ItemAt(i));
|
||||
BPath packageDir(pkgRootDir.Path(), p->Folder());
|
||||
err = engine.CollectTargets(packageDir.Path());
|
||||
if (err != B_OK)
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
// copy source volume
|
||||
err = engine.CopyFolder(srcDirectory.Path(), targetDirectory.Path(),
|
||||
fCancelLock);
|
||||
@ -396,11 +415,11 @@ WorkerThread::_PerformInstall(BMenu *srcMenu, BMenu *targetMenu)
|
||||
|
||||
// copy selected packages
|
||||
if (fPackages) {
|
||||
srcDirectory.Append(PACKAGES_DIRECTORY);
|
||||
BPath pkgRootDir(srcDirectory.Path(), PACKAGES_DIRECTORY);
|
||||
int32 count = fPackages->CountItems();
|
||||
for (int32 i = 0; i < count; i++) {
|
||||
Package *p = static_cast<Package*>(fPackages->ItemAt(i));
|
||||
BPath packageDir(srcDirectory.Path(), p->Folder());
|
||||
BPath packageDir(pkgRootDir.Path(), p->Folder());
|
||||
err = engine.CopyFolder(packageDir.Path(), targetDirectory.Path(),
|
||||
fCancelLock);
|
||||
if (err != B_OK)
|
||||
|
Loading…
Reference in New Issue
Block a user