Skip to content

Commit

Permalink
Reworking some more verbiage to avoid the word "cache" where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
tpill90 committed Sep 13, 2024
1 parent d4190d4 commit e190fc4
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 32 deletions.
16 changes: 8 additions & 8 deletions SteamPrefill/CliCommands/ClearTempCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
namespace SteamPrefill.CliCommands
{
[UsedImplicitly]
[Command("clear-temp", Description = "Empties out temporary cached data (from SteamPrefill), to free up disk space")]
[Command("clear-temp", Description = "Empties out temporary data, such as saved manifests, to free up disk space")]
public sealed class ClearTempCommand : ICommand
{
[CommandOption("yes", shortName: 'y', Description = "When specified, will clear the cache without prompting", Converter = typeof(NullableBoolConverter))]
[CommandOption("yes", shortName: 'y', Description = "When specified, will clear the temp files without prompting", Converter = typeof(NullableBoolConverter))]
public bool? AcceptPrompt { get; init; }

public ValueTask ExecuteAsync(IConsole console)
Expand All @@ -14,28 +14,28 @@ public ValueTask ExecuteAsync(IConsole console)

var ansiConsole = console.CreateAnsiConsole();
// Remove the v1/v2/v3 sub-directories
var rootCacheDir = new DirectoryInfo(AppConfig.CacheDir).Parent;
var rootCacheDir = new DirectoryInfo(AppConfig.TempDir).Parent;

// Scanning the cache directory to see how much space could be saved
List<FileInfo> cacheFolderContents = null;
ansiConsole.StatusSpinner().Start($"Scanning {Cyan("Cache")} directory...", ctx =>
ansiConsole.StatusSpinner().Start($"Scanning {Cyan("temp")} directory...", ctx =>
{
cacheFolderContents = rootCacheDir.EnumerateFiles("*.*", SearchOption.AllDirectories).ToList();
});

var totalSizeOnDisk = ByteSize.FromBytes(cacheFolderContents.Sum(e => e.Length));
if (totalSizeOnDisk.Bytes == 0 && cacheFolderContents.Count == 0)
{
ansiConsole.LogMarkupLine($"Nothing to cleanup! {Cyan("Cache")} directory is already empty!");
ansiConsole.LogMarkupLine($"Nothing to cleanup! {Cyan("temp")} directory is already empty!");
return default;
}
ansiConsole.LogMarkupLine($"Found {LightYellow(cacheFolderContents.Count)} cached files, totaling {Magenta(totalSizeOnDisk.ToDecimalString())}");
ansiConsole.LogMarkupLine($"Found {LightYellow(cacheFolderContents.Count)} temp files, totaling {Magenta(totalSizeOnDisk.ToDecimalString())}");

// If user hasn't passed in the accept flag, then we should ask them if they want to delete the files
if (!(AcceptPrompt ?? false))
{
var userResponse = ansiConsole.Prompt(new SelectionPrompt<bool>()
.Title("Continue to empty cache?")
.Title("Continue to delete temp files?")
.AddChoices(true, false)
.UseConverter(e => e == false ? "No" : "Yes"));
filesShouldBeDeleted = filesShouldBeDeleted || userResponse;
Expand All @@ -46,7 +46,7 @@ public ValueTask ExecuteAsync(IConsole console)
return default;
}

ansiConsole.StatusSpinner().Start("Deleting cached files...", ctx =>
ansiConsole.StatusSpinner().Start("Deleting temp files...", ctx =>
{
Directory.Delete(rootCacheDir.FullName, true);
});
Expand Down
2 changes: 1 addition & 1 deletion SteamPrefill/CliCommands/PrefillCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public async ValueTask ExecuteAsync(IConsole console)
// Property must be set to false in order to disable ansi escape sequences
_ansiConsole.Profile.Capabilities.Ansi = !NoAnsiEscapeSequences ?? true;

await UpdateChecker.CheckForUpdatesAsync(typeof(Program), "tpill90/steam-lancache-prefill", AppConfig.CacheDir);
await UpdateChecker.CheckForUpdatesAsync(typeof(Program), "tpill90/steam-lancache-prefill", AppConfig.TempDir);

var downloadArgs = new DownloadArguments
{
Expand Down
2 changes: 1 addition & 1 deletion SteamPrefill/Models/DepotInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public sealed class DepotInfo

public ulong? ManifestId { get; set; }

public string ManifestFileName => $"{AppConfig.CacheDir}/{_originalAppId}_{ContainingAppId}_{DepotId}_{ManifestId}.bin";
public string ManifestFileName => $"{AppConfig.TempDir}/{_originalAppId}_{ContainingAppId}_{DepotId}_{ManifestId}.bin";

/// <summary>
/// Determines what app actually owns the depot, by default it is the current app.
Expand Down
21 changes: 8 additions & 13 deletions SteamPrefill/Settings/AppConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ static AppConfig()
{
// Create required folders
Directory.CreateDirectory(ConfigDir);
Directory.CreateDirectory(CacheDir);
Directory.CreateDirectory(TempDir);
}

/// <summary>
Expand All @@ -31,12 +31,7 @@ public static bool VerboseLogs
/// Downloaded manifests, as well as other metadata, are saved into this directory to speedup future prefill runs.
/// All data in here should be able to be deleted safely.
/// </summary>
public static readonly string CacheDir = CacheDirUtils.GetCacheDirBaseDirectories("SteamPrefill", CacheDirVersion);

/// <summary>
/// Increment when there is a breaking change made to the files in the cache directory
/// </summary>
private const string CacheDirVersion = "v1";
public static readonly string TempDir = CacheDirUtils.GetCacheDirBaseDirectories("SteamPrefill", "v1");

/// <summary>
/// Contains user configuration. Should not be deleted, doing so will reset the app back to defaults.
Expand All @@ -54,22 +49,22 @@ public static bool VerboseLogs
public static readonly string UserSelectedAppsPath = Path.Combine(ConfigDir, "selectedAppsToPrefill.json");

/// <summary>
/// Keeps track of which depots have been previously downloaded. Is used to determine whether or not a game is up to date,
/// based on whether all of the depots being downloaded are up to date.
/// Keeps track of which depots have been previously downloaded. Is used to determine whether a game is up-to-date,
/// based on whether all the depots being downloaded are up-to-date.
/// </summary>
public static readonly string SuccessfullyDownloadedDepotsPath = Path.Combine(ConfigDir, "successfullyDownloadedDepots.json");

/// <summary>
/// Stores the user's current CellId, which corresponds to their region.
/// Stores the user's current CellId, which corresponds to their region.
/// </summary>
/// <see cref="Steam3Session.CellId">See for additional documentation</see>
public static readonly string CachedCellIdPath = Path.Combine(CacheDir, "cellId.txt");
public static readonly string CachedCellIdPath = Path.Combine(TempDir, "cellId.txt");

#endregion

#region Debugging
#region Debugging

public static readonly string DebugOutputDir = Path.Combine(CacheDir, "Debugging");
public static readonly string DebugOutputDir = Path.Combine(TempDir, "Debugging");

/// <summary>
/// Skips using locally cached manifests. Saves disk space, at the expense of slower subsequent runs. Intended for debugging.
Expand Down
12 changes: 7 additions & 5 deletions docs/mkdocs/detailed-command-usage/Clear-Temp.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@
<br>

## Overview
Deletes temporary cached manifests stored in the `/Cache` directory.
These files are cached in order to dramatically speed up future `prefill` runs (in some cases 3X faster).
For most users it isn't necessary to use this command, however it may be useful to free up some disk space if you are running low on storage.
Deletes temporary data created by {{prefill_name}}, such as saved manifests, to free up disk space.

These files are saved locally in order to dramatically speed up future `prefill` runs (in some cases 3X faster), at the expense of increase disk usage. These cached manifests will also build up over time, as newer versions of games are released, leaving unused manifests behind that will never be used again.

For most users it isn't necessary to use this command, however it may be useful to free up some disk space if you are running low on storage, or to reset any temp data to assist with debugging {{prefill_name}}.


These cached manifests will also build up over time, as newer versions of games are released, leaving unused manifests behind that will never be used again.

-----

## Options

| Option | | |
| ----------- | --- | --- |
| --yes | -y | Skips the prompt asking to clear the cache, and immediately begins clearing the cache. |
| --yes | -y | Clears the temp files immediately, displaying a prompt. |
8 changes: 4 additions & 4 deletions docs/mkdocs/detailed-command-usage/casts/clear-temp.cast
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
[0.070479, "o", "\u001b[?1h\u001b="]
[0.070977, "o", "\u001b[39;49m"]
[0.097002, "o", "\u001b[?25l"]
[0.124736, "o", " \r\n\u001b[38;5;2m⣾\u001b[0m Scanning \u001b[38;5;80mCache\u001b[0m directory...\r\n "]
[0.124736, "o", " \r\n\u001b[38;5;2m⣾\u001b[0m Scanning \u001b[38;5;80mTemp\u001b[0m directory...\r\n "]
[0.124955, "o", "\r\u001b[2K\u001b[1A\u001b[2K\u001b[1A\u001b[2K"]
[0.125015, "o", "\u001b[?25h"]
[0.125779, "o", "[6:08:17 PM] Found \u001b[38;5;229m142\u001b[0m cached files, totaling \u001b[38;5;170m26.49 MiB\u001b[0m\r\n"]
[0.137423, "o", "\u001b[?25lContinue to empty cache?\r\n \r\n\u001b[38;5;12m> Yes\u001b[0m \r\n No "]
[0.13761, "o", "\r\u001b[3AContinue to empty cache?\r\n \r\n\u001b[38;5;12m> Yes\u001b[0m \r\n No "]
[0.125779, "o", "[6:08:17 PM] Found \u001b[38;5;229m142\u001b[0m temp files, totaling \u001b[38;5;170m26.49 MiB\u001b[0m\r\n"]
[0.137423, "o", "\u001b[?25lContinue to delete temp files?\r\n \r\n\u001b[38;5;12m> Yes\u001b[0m \r\n No "]
[0.13761, "o", "\r\u001b[3AContinue to delete temp files?\r\n \r\n\u001b[38;5;12m> Yes\u001b[0m \r\n No "]

0 comments on commit e190fc4

Please sign in to comment.