1
0
mirror of https://github.com/veracrypt/VeraCrypt.git synced 2026-06-09 22:36:59 -05:00

Linux/macOS: show volume creation finalization stages

Report explicit progress stages while writing volume data, writing backup headers, and flushing data to disk so the wizard does not appear stuck at 100%.

Keep the wizard in progress during Unix post-creation formatting and show status for temporary mount/device setup, mkfs invocation, and dismount.
This commit is contained in:
Mounir IDRASSI
2026-05-03 00:03:04 +09:00
parent 8b80e2fc61
commit f8837090b8
49 changed files with 574 additions and 12 deletions
@@ -22,7 +22,9 @@ namespace VeraCrypt
ProgressBarRange (1),
RealProgressBarRange (1),
VolumeCreatorRunning (false),
MouseEventsCounter (0)
MouseEventsCounter (0),
CurrentProgressStage (VolumeCreator::ProgressStage::NotStarted),
MaxStaticTextWidth (-1)
{
DisplayKeysCheckBox->SetValue (displayKeyInfo);
#ifdef TC_WINDOWS
@@ -170,9 +172,61 @@ namespace VeraCrypt
void VolumeCreationProgressWizardPage::SetMaxStaticTextWidth (int width)
{
MaxStaticTextWidth = width;
InfoStaticText->Wrap (width);
}
void VolumeCreationProgressWizardPage::SetPageText (const wxString &text)
{
InfoStaticText->SetLabel (text);
if (MaxStaticTextWidth > 0)
InfoStaticText->Wrap (MaxStaticTextWidth);
Layout();
if (GetParent())
GetParent()->Layout();
}
void VolumeCreationProgressWizardPage::SetProgressStage (VolumeCreator::ProgressStage::Enum stage)
{
if (stage == CurrentProgressStage)
return;
CurrentProgressStage = stage;
switch (stage)
{
case VolumeCreator::ProgressStage::WritingData:
SetPageText (LangString["FORMAT_STAGE_WRITING_DATA"]);
break;
case VolumeCreator::ProgressStage::WritingBackupHeader:
SetPageText (LangString["FORMAT_STAGE_WRITING_BACKUP_HEADER"]);
break;
case VolumeCreator::ProgressStage::FlushingData:
SetPageText (LangString["FORMAT_STAGE_FLUSHING_DATA"]);
break;
case VolumeCreator::ProgressStage::Finished:
SetPageText (LangString["FORMAT_STAGE_FINISHED"]);
break;
case VolumeCreator::ProgressStage::Aborted:
SetPageText (LangString["FORMAT_STAGE_ABORTED"]);
break;
case VolumeCreator::ProgressStage::Error:
SetPageText (LangString["FORMAT_STAGE_ERROR"]);
break;
case VolumeCreator::ProgressStage::NotStarted:
default:
break;
}
}
void VolumeCreationProgressWizardPage::SetProgressState (bool volumeCreatorRunning)
{
if (volumeCreatorRunning)
@@ -30,8 +30,9 @@ namespace VeraCrypt
void OnRandomPoolTimer ();
void SetKeyInfo (const VolumeCreator::KeyInfo &keyInfo);
void SetMaxStaticTextWidth (int width);
void SetPageText (const wxString &text) { InfoStaticText->SetLabel (text); }
void SetPageText (const wxString &text);
void SetProgressRange (uint64 progressBarRange);
void SetProgressStage (VolumeCreator::ProgressStage::Enum stage);
void SetProgressValue (uint64 value);
void SetProgressState (bool volumeCreatorRunning);
void IncrementEntropyProgress ();
@@ -54,6 +55,8 @@ namespace VeraCrypt
bool VolumeCreatorRunning;
int MouseEventsCounter;
Mutex AccessMutex;
VolumeCreator::ProgressStage::Enum CurrentProgressStage;
int MaxStaticTextWidth;
};
}
+48 -9
View File
@@ -429,11 +429,14 @@ namespace VeraCrypt
VolumeCreator::ProgressInfo progress = Creator->GetProgressInfo();
VolumeCreationProgressWizardPage *page = dynamic_cast <VolumeCreationProgressWizardPage *> (GetCurrentPage());
page->SetProgressValue (progress.SizeDone);
if (page)
{
page->SetProgressStage (progress.Stage);
page->SetProgressValue (progress.SizeDone);
}
if (!progress.CreationInProgress && !AbortConfirmationPending)
{
SetWorkInProgress (false);
OnVolumeCreatorFinished ();
}
}
@@ -447,16 +450,29 @@ namespace VeraCrypt
}
}
void VolumeCreationWizard::SetCreationProgressText (const wxString &text)
{
VolumeCreationProgressWizardPage *page = dynamic_cast <VolumeCreationProgressWizardPage *> (GetCurrentPage());
if (!page)
return;
page->SetPageText (text);
page->Refresh();
page->Update();
Gui->Yield();
}
void VolumeCreationWizard::OnVolumeCreatorFinished ()
{
VolumeCreationProgressWizardPage *page = dynamic_cast <VolumeCreationProgressWizardPage *> (GetCurrentPage());
ProgressTimer.reset();
page->SetProgressState (false);
Gui->EndInteractiveBusyState (this);
SetWorkInProgress (false);
UpdateControls();
if (page)
{
page->SetProgressState (false);
page->EnableAbort (false);
}
bool workInProgressCleared = false;
try
{
@@ -472,6 +488,8 @@ namespace VeraCrypt
{
wxBusyCursor busy;
SetCreationProgressText (LangString["FORMAT_STAGE_PREPARING_TEMP_VOLUME"]);
MountOptions mountOptions (Gui->GetPreferences().DefaultMountOptions);
mountOptions.Path = make_shared <VolumePath> (SelectedVolumePath);
mountOptions.NoFilesystem = true;
@@ -483,10 +501,11 @@ namespace VeraCrypt
shared_ptr <VolumeInfo> volume = Core->MountVolume (mountOptions);
finally_do_arg (shared_ptr <VolumeInfo>, volume, { Core->DismountVolume (finally_arg, true); });
shared_ptr <VolumeLayout> layout((volume->Type == VolumeType::Normal)? (VolumeLayout*) new VolumeLayoutV2Normal() : (VolumeLayout*) new VolumeLayoutV2Hidden());
uint64 filesystemSize = layout->GetMaxDataSize (VolumeSize);
SetCreationProgressText (LangString["FORMAT_STAGE_PREPARING_TEMP_DEVICE"]);
Thread::Sleep (2000); // Try to prevent race conditions caused by OS
// Temporarily take ownership of the device if the user is not an administrator
@@ -540,10 +559,16 @@ namespace VeraCrypt
args.push_back (string (virtualDevice));
SetCreationProgressText (StringFormatter (LangString["FORMAT_STAGE_CREATING_FILESYSTEM"], fsFormatter));
Process::Execute (fsFormatter, args);
SetCreationProgressText (LangString["FORMAT_STAGE_DISMOUNTING_TEMP_VOLUME"]);
}
#endif // TC_UNIX
Gui->EndInteractiveBusyState (this);
SetWorkInProgress (false);
workInProgressCleared = true;
if (OuterVolume)
{
SetStep (Step::OuterVolumeContents);
@@ -559,10 +584,24 @@ namespace VeraCrypt
}
catch (exception &e)
{
if (!workInProgressCleared)
{
Gui->EndInteractiveBusyState (this);
SetWorkInProgress (false);
workInProgressCleared = true;
}
Gui->ShowError (e);
}
page->SetProgressValue (0);
if (!workInProgressCleared)
{
Gui->EndInteractiveBusyState (this);
SetWorkInProgress (false);
}
if (page)
page->SetProgressValue (0);
if (SelectedVolumeType == VolumeType::Normal && !SelectedVolumePath.IsDevice())
{
try
+1
View File
@@ -59,6 +59,7 @@ namespace VeraCrypt
void OnThreadExiting (wxCommandEvent& event);
void OnVolumeCreatorFinished ();
WizardStep ProcessPageChangeRequest (bool forward);
void SetCreationProgressText (const wxString &text);
volatile bool AbortConfirmationPending;
volatile bool AbortRequested;