add free drive space display, file compactor hint, recalculate size after compacting

This commit is contained in:
rootdarkarchon
2024-02-14 18:57:18 +01:00
committed by Loporrit
parent 08eb1d194a
commit 50990542fd
3 changed files with 23 additions and 7 deletions

View File

@@ -61,6 +61,7 @@ public sealed class CacheMonitor : DisposableMediatorSubscriberBase
public long CurrentFileProgress => _currentFileProgress; public long CurrentFileProgress => _currentFileProgress;
public long FileCacheSize { get; set; } public long FileCacheSize { get; set; }
public long FileCacheDriveFree { get; set; }
public ConcurrentDictionary<string, int> HaltScanLocks { get; set; } = new(StringComparer.Ordinal); public ConcurrentDictionary<string, int> HaltScanLocks { get; set; } = new(StringComparer.Ordinal);
public bool IsScanRunning => CurrentFileProgress > 0 || TotalFiles > 0; public bool IsScanRunning => CurrentFileProgress > 0 || TotalFiles > 0;
public long TotalFiles { get; private set; } public long TotalFiles { get; private set; }
@@ -369,6 +370,9 @@ public sealed class CacheMonitor : DisposableMediatorSubscriberBase
} }
}); });
DriveInfo di = new DriveInfo(new DirectoryInfo(_configService.Current.CacheFolder).Root.FullName);
FileCacheDriveFree = di.AvailableFreeSpace;
var maxCacheInBytes = (long)(_configService.Current.MaxLocalCacheInGiB * 1024d * 1024d * 1024d); var maxCacheInBytes = (long)(_configService.Current.MaxLocalCacheInGiB * 1024d * 1024d * 1024d);
if (FileCacheSize < maxCacheInBytes) return false; if (FileCacheSize < maxCacheInBytes) return false;

View File

@@ -784,10 +784,16 @@ public class SettingsUi : WindowMediatorSubscriberBase
} }
_uiShared.DrawCacheDirectorySetting(); _uiShared.DrawCacheDirectorySetting();
ImGui.TextUnformatted($"Currently utilized local storage: {UiSharedService.ByteToString(_uiShared.FileCacheSize)}"); ImGui.AlignTextToFramePadding();
bool isLinux = Util.IsWine(); ImGui.TextUnformatted($"Currently utilized local storage: {UiSharedService.ByteToString(_cacheMonitor.FileCacheSize)}");
if (isLinux) ImGui.BeginDisabled(); ImGui.TextUnformatted($"Remaining space free on drive: {UiSharedService.ByteToString(_cacheMonitor.FileCacheDriveFree)}");
bool useFileCompactor = _configService.Current.UseCompactor; bool useFileCompactor = _configService.Current.UseCompactor;
bool isLinux = Util.IsWine();
if (!useFileCompactor && !isLinux)
{
UiSharedService.ColorTextWrapped("Hint: To free up space when using Mare consider enabling the File Compactor", ImGuiColors.DalamudYellow);
}
if (isLinux) ImGui.BeginDisabled();
if (ImGui.Checkbox("Use file compactor", ref useFileCompactor)) if (ImGui.Checkbox("Use file compactor", ref useFileCompactor))
{ {
_configService.Current.UseCompactor = useFileCompactor; _configService.Current.UseCompactor = useFileCompactor;
@@ -800,14 +806,22 @@ public class SettingsUi : WindowMediatorSubscriberBase
{ {
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.FileArchive, "Compact all files in storage")) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.FileArchive, "Compact all files in storage"))
{ {
_ = Task.Run(() => _fileCompactor.CompactStorage(compress: true)); _ = Task.Run(() =>
{
_fileCompactor.CompactStorage(compress: true);
_ = _cacheMonitor.RecalculateFileCacheSize();
});
} }
UiSharedService.AttachToolTip("This will run compression on all files in your current storage folder." + Environment.NewLine UiSharedService.AttachToolTip("This will run compression on all files in your current storage folder." + Environment.NewLine
+ "You do not need to run this manually if you keep the file compactor enabled."); + "You do not need to run this manually if you keep the file compactor enabled.");
ImGui.SameLine(); ImGui.SameLine();
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.File, "Decompact all files in storage")) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.File, "Decompact all files in storage"))
{ {
_ = Task.Run(() => _fileCompactor.CompactStorage(compress: false)); _ = Task.Run(() =>
{
_fileCompactor.CompactStorage(compress: false);
_ = _cacheMonitor.RecalculateFileCacheSize();
});
} }
UiSharedService.AttachToolTip("This will run decompression on all files in your current storage folder."); UiSharedService.AttachToolTip("This will run decompression on all files in your current storage folder.");
} }

View File

@@ -123,8 +123,6 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
public bool EditTrackerPosition { get; set; } public bool EditTrackerPosition { get; set; }
public long FileCacheSize => _cacheMonitor.FileCacheSize;
public bool HasValidPenumbraModPath => !(_ipcManager.PenumbraModDirectory ?? string.Empty).IsNullOrEmpty() && Directory.Exists(_ipcManager.PenumbraModDirectory); public bool HasValidPenumbraModPath => !(_ipcManager.PenumbraModDirectory ?? string.Empty).IsNullOrEmpty() && Directory.Exists(_ipcManager.PenumbraModDirectory);
public bool IsInGpose => _dalamudUtil.IsInCutscene; public bool IsInGpose => _dalamudUtil.IsInCutscene;