Skip to content

Commit

Permalink
Fixes size estimation in distros such as NixOS with exotic folder str…
Browse files Browse the repository at this point in the history
…ucture
  • Loading branch information
okibcn authored Mar 1, 2023
1 parent 4d0685a commit 79c53f8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions WslCompact/WslCompact.psm1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# WslCompact v8.5 2023.02.16
# WslCompact v8.7 2023.03.01
# (C) 2023 Oscar Lopez.
# For more information visit: https://github.com/okibcn/wslcompact
#
Expand All @@ -20,7 +20,7 @@ function WslCompact {
$arg
}
}
Write-Host " WslCompact v8.5 2023.02.16
Write-Host " WslCompact v8.7 2023.03.01
(C) 2023 Oscar Lopez
wslcompact -h for help. For more information visit: https://github.com/okibcn/wslcompact"

Expand Down Expand Up @@ -76,7 +76,8 @@ function WslCompact {
$estimated = [long]($size1)
}
else {
$estimated = ((wsl -d "$wsl_distro" -e df /) | Select-String -Pattern "(?<=^\/dev[^\s]+\s+\d+\s+)\d+" ).Matches[0].Value
$dfpath=((wsl -d "$wsl_distro" which df) 2>$null | sls "^/.*df$").Matches.value
$estimated = ((wsl -d "$wsl_distro" -e "$dfpath" /) | sls -Pattern "(?<=^\/dev[^\s]+\s+\d+\s+)\d+" ).Matches[0].Value
$estimated = [long]($estimated / 1024)
Write-Host " Estimated size: $([long]($estimated * ((($sf - 1) / 2) + 1))) +/- $([long]($estimated * ($sf - 1) / 2)) MB"
Write-Host " The estimated process time using an SSD is about $([math]::ceiling($estimated/4000)) minutes."
Expand Down

1 comment on commit 79c53f8

@okibcn
Copy link
Owner Author

@okibcn okibcn commented on 79c53f8 Mar 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix solves issue #9

Please sign in to comment.