* Only except BFS partitions as target volumes. Installer does not initialize
partitions by itself. When it does, this check can be removed again... for now DriveSetup is to be used and so there is no code duplication. * Check if the target volume is non-empty and present an appropriate warning. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30382 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -128,7 +128,9 @@ CopyEngine::Start(BMenu *srcMenu, BMenu *targetMenu)
|
|||||||
BPartition *partition;
|
BPartition *partition;
|
||||||
BVolume targetVolume;
|
BVolume targetVolume;
|
||||||
status_t err = B_OK;
|
status_t err = B_OK;
|
||||||
|
int32 entries = 0;
|
||||||
|
entry_ref testRef;
|
||||||
|
|
||||||
fControl->Reset();
|
fControl->Reset();
|
||||||
|
|
||||||
PartitionMenuItem *targetItem = (PartitionMenuItem *)targetMenu->FindMarked();
|
PartitionMenuItem *targetItem = (PartitionMenuItem *)targetMenu->FindMarked();
|
||||||
@@ -210,17 +212,69 @@ CopyEngine::Start(BMenu *srcMenu, BMenu *targetMenu)
|
|||||||
// check not installing on boot volume
|
// check not installing on boot volume
|
||||||
if ((strncmp(BOOT_PATH, targetDirectory.Path(), strlen(BOOT_PATH)) == 0)
|
if ((strncmp(BOOT_PATH, targetDirectory.Path(), strlen(BOOT_PATH)) == 0)
|
||||||
&& ((new BAlert("", "Are you sure you want to install onto the "
|
&& ((new BAlert("", "Are you sure you want to install onto the "
|
||||||
"current boot disk? The installer will have to reboot your "
|
"current boot disk? The Installer will have to reboot your "
|
||||||
"machine if you proceed.", "OK", "Cancel", 0,
|
"machine if you proceed.", "OK", "Cancel", 0,
|
||||||
B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go() != 0)) {
|
B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go() != 0)) {
|
||||||
SetStatusMessage("Installation stopped.");
|
SetStatusMessage("Installation stopped.");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
targetDir.SetTo(targetDirectory.Path());
|
||||||
|
|
||||||
|
// check target volume not empty
|
||||||
|
// NOTE: It's ok if exactly this path exists: home/Desktop/Trash
|
||||||
|
// and nothing else.
|
||||||
|
while (targetDir.GetNextRef(&testRef) == B_OK) {
|
||||||
|
if (strcmp(testRef.name, "home") == 0) {
|
||||||
|
BDirectory homeDir(&testRef);
|
||||||
|
while (homeDir.GetNextRef(&testRef) == B_OK) {
|
||||||
|
if (strcmp(testRef.name, "Desktop") == 0) {
|
||||||
|
BDirectory desktopDir(&testRef);
|
||||||
|
while (desktopDir.GetNextRef(&testRef) == B_OK) {
|
||||||
|
if (strcmp(testRef.name, "Trash") == 0) {
|
||||||
|
BDirectory trashDir(&testRef);
|
||||||
|
while (trashDir.GetNextRef(&testRef) == B_OK) {
|
||||||
|
// Something in the Trash
|
||||||
|
entries++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Something besides Trash
|
||||||
|
entries++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entries > 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Something besides Desktop
|
||||||
|
entries++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entries > 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Something besides home
|
||||||
|
entries++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entries > 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (entries != 0
|
||||||
|
&& ((new BAlert("", "The target volume is not empty. Are you sure you "
|
||||||
|
"want to install anyways?", "Install Anyways", "Cancel", 0,
|
||||||
|
B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go() != 0)) {
|
||||||
|
err = B_CANCELED;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
LaunchInitScript(targetDirectory);
|
LaunchInitScript(targetDirectory);
|
||||||
|
|
||||||
// copy source volume
|
// copy source volume
|
||||||
targetDir.SetTo(targetDirectory.Path());
|
targetDir.Rewind();
|
||||||
srcDir.SetTo(srcDirectory.Path());
|
srcDir.SetTo(srcDirectory.Path());
|
||||||
err = CopyFolder(srcDir, targetDir);
|
err = CopyFolder(srcDir, targetDir);
|
||||||
|
|
||||||
@@ -296,11 +350,11 @@ CopyEngine::ScanDisksPartitions(BMenu *srcMenu, BMenu *targetMenu)
|
|||||||
BDiskDevice device;
|
BDiskDevice device;
|
||||||
BPartition *partition = NULL;
|
BPartition *partition = NULL;
|
||||||
|
|
||||||
printf("ScanDisksPartitions partitions begin\n");
|
printf("\nScanDisksPartitions source partitions begin\n");
|
||||||
SourceVisitor srcVisitor(srcMenu);
|
SourceVisitor srcVisitor(srcMenu);
|
||||||
fDDRoster.VisitEachMountedPartition(&srcVisitor, &device, &partition);
|
fDDRoster.VisitEachMountedPartition(&srcVisitor, &device, &partition);
|
||||||
|
|
||||||
printf("ScanDisksPartitions partitions begin\n");
|
printf("\nScanDisksPartitions target partitions begin\n");
|
||||||
TargetVisitor targetVisitor(targetMenu);
|
TargetVisitor targetVisitor(targetMenu);
|
||||||
fDDRoster.VisitEachPartition(&targetVisitor, &device, &partition);
|
fDDRoster.VisitEachPartition(&targetVisitor, &device, &partition);
|
||||||
}
|
}
|
||||||
@@ -344,7 +398,7 @@ SourceVisitor::Visit(BPartition *partition, int32 level)
|
|||||||
printf("SourceVisitor::Visit(BPartition *) : %s\n", path.Path());
|
printf("SourceVisitor::Visit(BPartition *) : %s\n", path.Path());
|
||||||
printf("SourceVisitor::Visit(BPartition *) : %s\n", partition->ContentName());
|
printf("SourceVisitor::Visit(BPartition *) : %s\n", partition->ContentName());
|
||||||
|
|
||||||
if (!partition->ContentType())
|
if (partition->ContentType() == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bool isBootPartition = false;
|
bool isBootPartition = false;
|
||||||
@@ -401,6 +455,13 @@ TargetVisitor::Visit(BPartition *partition, int32 level)
|
|||||||
printf("TargetVisitor::Visit(BPartition *) : %s\n", path.Path());
|
printf("TargetVisitor::Visit(BPartition *) : %s\n", path.Path());
|
||||||
printf("TargetVisitor::Visit(BPartition *) : %s\n", partition->ContentName());
|
printf("TargetVisitor::Visit(BPartition *) : %s\n", partition->ContentName());
|
||||||
|
|
||||||
|
if (partition->ContentType() == NULL
|
||||||
|
|| strcmp(partition->ContentType(), kPartitionTypeBFS) != 0) {
|
||||||
|
// Except only valid BFS partitions
|
||||||
|
printf(" not BFS\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (partition->ContentSize() < 20 * 1024 * 1024) {
|
if (partition->ContentSize() < 20 * 1024 * 1024) {
|
||||||
// reject partitions which are too small anyways
|
// reject partitions which are too small anyways
|
||||||
// TODO: Could depend on the source size
|
// TODO: Could depend on the source size
|
||||||
|
|||||||
@@ -447,8 +447,8 @@ InstallerWindow::QuitRequested()
|
|||||||
"Installer window.", "OK"))->Go();
|
"Installer window.", "OK"))->Go();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
|
||||||
fCopyEngine->PostMessage(B_QUIT_REQUESTED);
|
fCopyEngine->PostMessage(B_QUIT_REQUESTED);
|
||||||
|
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user