Best way to get an overall % when ExtractImage
Closed this issue · 3 comments
SuperJMN commented
Hello! First of all, thanks for this wonderful wrapper :)
I'm trying to report a % while the image is being extracted. I first thought that I could get it taking a look to the ProgressInfo_Extract
propertires CurrentFileCount
and EndFileCount
, but I was wrong.
I'm no longer sure about how to calculate the global % of the progress. How can I do it?
Thanks in advance!
ied206 commented
Wimlib takes 3 steps to apply the image, and each of the steps has it's own ProgressInfo_Extract
.
In my case, I assigned a coefficient to each step to calculate global progress.
- ProgressMsg.EXTRACT_FILE_STRUCTURE : 0-10%
- ProgressMsg.EXTRACT_STREAMS : 10-90%
- ProgressMsg.EXTRACT_METADATA : 90-100%
Example
switch (msg)
{
case ProgressMsg.EXTRACT_FILE_STRUCTURE:
{ // Used file count
ProgressInfo_Extract m = (ProgressInfo_Extract)info;
if (0 < m.EndFileCount)
{
ulong percentComplete = m.CurrentFileCount * 10 / m.EndFileCount;
s.MainViewModel.BuildCommandProgressValue = percentComplete;
s.MainViewModel.BuildCommandProgressText = $"[Stage 1] Creating files... ({percentComplete}%)";
}
}
break;
case ProgressMsg.EXTRACT_STREAMS:
{ // Used bytes
ProgressInfo_Extract m = (ProgressInfo_Extract)info;
if (0 < m.TotalBytes)
{
ulong percentComplete = 10 + m.CompletedBytes * 80 / m.TotalBytes;
s.MainViewModel.BuildCommandProgressValue = percentComplete;
s.MainViewModel.BuildCommandProgressText = $"[Stage 2] Extracting file data... ({percentComplete}%)";
}
}
break;
case ProgressMsg.EXTRACT_METADATA:
{ // Used count
ProgressInfo_Extract m = (ProgressInfo_Extract)info;
if (0 < m.EndFileCount)
{
ulong percentComplete = 90 + m.CurrentFileCount * 10 / m.EndFileCount;
s.MainViewModel.BuildCommandProgressValue = percentComplete;
s.MainViewModel.BuildCommandProgressText = $"[Stage 3] Applying metadata to files... ({percentComplete}%)";
}
}
break;
}
return CallbackStatus.CONTINUE;
SuperJMN commented
Thank you! I'm about to try it!
ied206 commented
Closing the issue.