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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
end-to-start, eliminating O(n²) array shifting (CQ-001).
- **Shortcut Cleaner** — COM objects (`IShellLink`, `IPersistFile`) now
released via `Marshal.ReleaseComObject` in finally block (SEC-006).
- **Models** — deduplicated `FormatSize` from `DiskUsageEntry`, `InstalledApp`,
and `ProcessEntry`; all now use `CleanupCategory.HumanSize` (CQ-002).
- **Console** — batch-remove excess lines from end-to-start instead of
repeated `RemoveAt(0)`, reducing O(n) per append to amortized O(1) (CQ-008).

### Security
- **Speed Test** — improved download integrity comment and added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void OpenFileLocation_NonExistentPath_DoesNotThrow()
public void ProcessEntry_MemoryDisplay_FormatsCorrectly()
{
var entry = new ProcessEntry { MemoryBytes = 52_428_800 }; // 50 MB
Assert.Equal("50.0 MB", entry.MemoryDisplay);
Assert.Equal("50 MB", entry.MemoryDisplay);
}

[Fact]
Expand Down
10 changes: 1 addition & 9 deletions SysManager/SysManager/Models/DiskUsageEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,5 @@ public partial class DiskUsageEntry : ObservableObject
[ObservableProperty] private bool _isAccessDenied;

/// <summary>Formatted size for display.</summary>
public string SizeDisplay => FormatSize(SizeBytes);

private static string FormatSize(long bytes) => bytes switch
{
>= 1L << 30 => $"{bytes / (double)(1L << 30):F1} GB",
>= 1L << 20 => $"{bytes / (double)(1L << 20):F1} MB",
>= 1L << 10 => $"{bytes / (double)(1L << 10):F1} KB",
_ => $"{bytes} B"
};
public string SizeDisplay => CleanupCategory.HumanSize(SizeBytes);
}
10 changes: 1 addition & 9 deletions SysManager/SysManager/Models/InstalledApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,5 @@ public partial class InstalledApp : ObservableObject
[ObservableProperty] private ImageSource? _icon;

/// <summary>Formatted size for display.</summary>
public string SizeDisplay => SizeBytes > 0 ? FormatSize(SizeBytes) : "—";

private static string FormatSize(long bytes) => bytes switch
{
>= 1L << 30 => $"{bytes / (double)(1L << 30):F1} GB",
>= 1L << 20 => $"{bytes / (double)(1L << 20):F1} MB",
>= 1L << 10 => $"{bytes / (double)(1L << 10):F1} KB",
_ => $"{bytes} B"
};
public string SizeDisplay => SizeBytes > 0 ? CleanupCategory.HumanSize(SizeBytes) : "—";
}
10 changes: 1 addition & 9 deletions SysManager/SysManager/Models/ProcessEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,5 @@ public partial class ProcessEntry : ObservableObject
&& System.IO.File.Exists(FilePath);

/// <summary>Formatted memory for display.</summary>
public string MemoryDisplay => FormatSize(MemoryBytes);

private static string FormatSize(long bytes) => bytes switch
{
>= 1L << 30 => $"{bytes / (double)(1L << 30):F1} GB",
>= 1L << 20 => $"{bytes / (double)(1L << 20):F1} MB",
>= 1L << 10 => $"{bytes / (double)(1L << 10):F1} KB",
_ => $"{bytes} B"
};
public string MemoryDisplay => CleanupCategory.HumanSize(MemoryBytes);
}
7 changes: 6 additions & 1 deletion SysManager/SysManager/ViewModels/ConsoleViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ public void Append(PowerShellLine line)
lock (_gate)
{
Lines.Add(line);
while (Lines.Count > MaxLines) Lines.RemoveAt(0);
if (Lines.Count > MaxLines)
{
var excess = Lines.Count - MaxLines;
for (int i = excess - 1; i >= 0; i--)
Lines.RemoveAt(i);
}
}
}

Expand Down
Loading