Skip to content

Commit

Permalink
Fix rdb init size using percentage
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikstengaard committed Dec 1, 2022
1 parent fc7e07d commit 12a2b93
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Hst.Imager.Core/Commands/RdbInitCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,15 @@ public override async Task<Result> Execute(CancellationToken token)
var defaultName = media.IsPhysicalDrive ? media.Model : Path.GetFileNameWithoutExtension(media.Model);

var diskSize = stream.Length;
var rigidDiskBlockSize = diskSize.ResolveSize(size);

OnDebugMessage($"Disk size '{diskSize.FormatBytes()}' ({diskSize} bytes)");

var rigidDiskBlock = diskGeometry != null
? CreateFromDiskGeometry(diskGeometry)
: RigidDiskBlock.Create(Convert.ToInt64(size.Value == 0 ? stream.Length : size.Value)
.ResolveSize(size));
: RigidDiskBlock.Create(rigidDiskBlockSize);

if (rigidDiskBlock.DiskSize > diskSize)
if (rigidDiskBlock.DiskSize > stream.Length)
{
return new Result(new Error($"Invalid Rigid Disk Block size '{rigidDiskBlock.DiskSize}' is larger than disk size '{diskSize}'"));
}
Expand Down

0 comments on commit 12a2b93

Please sign in to comment.