Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 3 additions & 23 deletions config/win-ops.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,37 +114,17 @@
{
"name": "MemoryCleanup",
"enabled": true,
"settings": {
"minWorkingSetMB": 50,
"minIdleMinutes": 10
}
"settings": {}
},
{
"name": "HistoryCleanup",
"enabled": true,
"settings": {
"clearRunDialog": true,
"clearExplorerPaths": true,
"clearExplorerSearch": true,
"clearJumpLists": true,
"clearRecentDocs": true,
"clearActivityTimeline": true,
"clearClipboard": true,
"clearShellHistory": true,
"clearWindowsSearch": true
}
"settings": {}
},
{
"name": "RegistryCleanup",
"enabled": true,
"settings": {
"backupBeforeDelete": true,
"cleanUninstallEntries": true,
"cleanSharedDLLs": true,
"cleanMUICache": true,
"cleanStartupEntries": true,
"cleanAppPaths": true
}
"settings": {}
}
],

Expand Down
20 changes: 10 additions & 10 deletions lib/core/Lock.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function Lock-WinOps {
}

# Write metadata to file
$metadata | ConvertTo-Json -Depth 3 | Set-Content -Path Get-LockMetadataPath -Force
$metadata | ConvertTo-Json -Depth 3 | Set-Content -Path (Get-LockMetadataPath) -Force

Write-Verbose "Lock acquired successfully (PID: $PID, Created: $createdNew)"
return $true
Expand All @@ -113,8 +113,8 @@ function Lock-WinOps {
$mutex.Dispose()

# Show who holds the lock
if (Test-Path Get-LockMetadataPath) {
$existingLock = Get-Content Get-LockMetadataPath -Raw | ConvertFrom-Json
if (Test-Path (Get-LockMetadataPath)) {
$existingLock = Get-Content (Get-LockMetadataPath) -Raw | ConvertFrom-Json
Write-Warning "Lock held by PID $($existingLock.PID) on $($existingLock.Hostname) since $($existingLock.StartTime)"
}

Expand Down Expand Up @@ -161,8 +161,8 @@ function Unlock-WinOps {
$script:LockMutex = $null

# Clean up metadata file
if (Test-Path Get-LockMetadataPath) {
Remove-Item -Path Get-LockMetadataPath -Force -ErrorAction SilentlyContinue
if (Test-Path (Get-LockMetadataPath)) {
Remove-Item -Path (Get-LockMetadataPath) -Force -ErrorAction SilentlyContinue
}

Write-Verbose "Lock released successfully"
Expand All @@ -184,8 +184,8 @@ function Unlock-WinOps {

$script:LockMutex = $null

if (Test-Path Get-LockMetadataPath) {
Remove-Item -Path Get-LockMetadataPath -Force -ErrorAction SilentlyContinue
if (Test-Path (Get-LockMetadataPath)) {
Remove-Item -Path (Get-LockMetadataPath) -Force -ErrorAction SilentlyContinue
}
}
}
Expand Down Expand Up @@ -285,13 +285,13 @@ function Clear-WinOpsStaleLock {
)

try {
if (-not (Test-Path Get-LockMetadataPath)) {
if (-not (Test-Path (Get-LockMetadataPath))) {
Write-Verbose "No lock metadata file found"
return $false
}

# Read existing lock metadata
$lockData = Get-Content Get-LockMetadataPath -Raw | ConvertFrom-Json
$lockData = Get-Content (Get-LockMetadataPath) -Raw | ConvertFrom-Json
$lockPID = $lockData.PID
$lockStartTime = [DateTime]::Parse($lockData.StartTime)
$lockAge = (Get-Date) - $lockStartTime
Expand All @@ -317,7 +317,7 @@ function Clear-WinOpsStaleLock {
Write-Warning "Clearing stale lock: $reason"

# Remove metadata file
Remove-Item -Path Get-LockMetadataPath -Force -ErrorAction Stop
Remove-Item -Path (Get-LockMetadataPath) -Force -ErrorAction Stop

# Try to acquire and release the mutex to clear it
try {
Expand Down
10 changes: 5 additions & 5 deletions scheduler/Invoke-WinOpsScheduled.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ try {
$params['DryRun'] = $true
}

if ($module.Settings) {
if ($module.Settings -and @($module.Settings.PSObject.Properties).Count -gt 0) {
foreach ($key in $module.Settings.PSObject.Properties.Name) {
$params[$key] = $module.Settings.$key
}
Expand Down Expand Up @@ -191,7 +191,7 @@ try {
$snapshotAfter = Get-WinOpsSnapshot -IncludeDisk -IncludeMemory

# Compare snapshots
$comparison = Compare-WinOpsSnapshot -Before $snapshotBefore -After $snapshotAfter
$comparison = Compare-WinOpsSnapshot -Before $snapshotBefore -After $snapshotAfter -Format Raw

# Generate summary
$totalFreedGB = [math]::Round($totalFreed / 1GB, 2)
Expand All @@ -211,9 +211,9 @@ Total Space Freed: $totalFreedGB GB
Disk Space Change:
"@

if ($comparison.Disks) {
foreach ($drive in $comparison.Disks.Keys) {
$diskChange = $comparison.Disks[$drive]
if ($comparison.Disk) {
foreach ($drive in $comparison.Disk.Keys) {
$diskChange = $comparison.Disk[$drive]
$summary += "`n $drive - Freed: $($diskChange.FreedGB) GB (Used: $($diskChange.BeforeUsedPercent)% -> $($diskChange.AfterUsedPercent)%)"
}
}
Expand Down