Skip to content

Commit

Permalink
fix first time install bug
Browse files Browse the repository at this point in the history
  • Loading branch information
reisir committed Nov 13, 2023
1 parent 0ee6eed commit 5f2c457
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
2 changes: 1 addition & 1 deletion @Resources/MonD.inc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ Description=Meters on Demand, the Rainmeter package manager
SkinName=Meters on Demand
LoadType=Skin
Load=Meters on Demand\Installer.ini
Version=v1.2.4
Version=v1.2.4b
HeaderImage=#@#mond.bmp
Exclude=cache.json | mond.log | plugins.log | temp
1 change: 1 addition & 0 deletions Installer.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ DefaultWindowX=50%
DefaultWindowY=50%
DefaultAnchorX=50%
DefaultAnchorY=50%
OnRefreshAction=[!About]
RightMouseUpAction=[]

[Variables]
Expand Down
36 changes: 29 additions & 7 deletions MetersOnDemand.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ param (

# Globals
$Self = [PSCustomObject]@{
Version = "v1.2.4";
Version = "v1.2.4b";
Directory = "#Mond";
FileName = "MetersOnDemand.ps1";
BatFileName = "mond.bat"
Expand Down Expand Up @@ -337,12 +337,21 @@ function Get-Request {
}

function Get-Cache {
[CmdletBinding()]
param (
[Parameter()]
[switch]
$SkipCache
)

$Cache = [PSCustomObject]@{
Skins = [pscustomobject]@{ };
Installed = [pscustomobject]@{ };
Updateable = [pscustomobject]@{ };
}

if($SkipCache) { return $Cache }

if (Test-Path -Path $cacheFile) {
$Cache = Get-Content -Path $cacheFile | ConvertFrom-Json
}
Expand All @@ -355,13 +364,18 @@ function Update-Cache {
[Parameter()]
[switch]
$SkipInstalled,
[Parameter(ValueFromPipeline)]
[PSCustomObject]
$Cache,
[Parameter()]
[switch]
$Force
)
if ($Cache -and !$Force) { return $Cache }

$Cache = Get-Cache
if(!$Cache) {
$Cache = Get-Cache
}

$CurrentDate = Get-Date -Format "MM-dd-yy"
if (!$Force -and ($Cache.LastChecked -eq $CurrentDate)) {
Expand Down Expand Up @@ -1006,11 +1020,12 @@ function InstallMetersOnDemand {
Write-Host "/////////////////"

Write-Host "Creating the cache"
$Cache = Update-Cache -Force
$Cache = Get-Cache
$Cache | Add-Member -MemberType NoteProperty -Name "SkinPath" -Value "$SkinPath" -Force
$Cache | Add-Member -MemberType NoteProperty -Name "SettingsPath" -Value "$SettingsPath" -Force
$Cache | Add-Member -MemberType NoteProperty -Name "ProgramPath" -Value "$ProgramPath" -Force
$Cache | Add-Member -MemberType NoteProperty -Name "ConfigEditor" -Value "$ConfigEditor" -Force
$Cache = Update-Cache -Cache $Cache -Force
$Cache = Save-Cache -Cache $Cache

Write-Host "Copying '$($Self.FileName)' & '$($Self.BatFileName)' to '$InstallPath'"
Expand Down Expand Up @@ -1100,7 +1115,7 @@ function Init {
New-Item -ItemType Directory -Path $ResourcesPath

# Create Mond.inc
@"
@"
[MonD]
Author=
PreviewImage=
Expand All @@ -1115,13 +1130,13 @@ HeaderImage=
"@ | Out-File -FilePath "$($ResourcesPath)\Mond.inc"

# Create the variables file
@"
@"
[Variables]
"@ | Out-File -FilePath "$($ResourcesPath)\Variables.inc"

# Create the skin
@"
@"
[Rainmeter]
DefaultUpdateDivider=-1
@IncludeVariables=#@#Variables.inc
Expand Down Expand Up @@ -1149,7 +1164,14 @@ Meter=Image
# Main body
if ($RmApi) {
if ($IsInstaller) {
InstallMetersOnDemand
try {
InstallMetersOnDemand
}
catch {
$RmApi.LogError("$($_)")
$_ | Out-File -FilePath $logFile -Append
$RmApi.Bang("[`"$($logFile)`"]")
}
}
return
}
Expand Down

0 comments on commit 5f2c457

Please sign in to comment.