Sweep VRChat cache function

This commit is contained in:
Natsumi
2021-05-23 01:41:06 +12:00
parent 7c0108cf54
commit 188d4a4972
3 changed files with 53 additions and 1 deletions

View File

@@ -238,7 +238,6 @@ namespace VRCX
Directory.Move(CacheSource, CacheDestinationLocation);
if (File.Exists(Path.Combine(VRChatCacheLocation, "Cache-WindowsPlayer", "__info")))
File.Delete(Path.Combine(VRChatCacheLocation, "Cache-WindowsPlayer", "__info"));
File.Move(Path.Combine(AssetBundleCacherTemp, "__info"), Path.Combine(VRChatCacheLocation, "Cache-WindowsPlayer", "__info"));
Directory.Delete(Path.Combine(VRChatCacheLocation, "AssetBundleCacher\\Cache", AssetId), true);
File.Delete(Path.Combine(VRChatCacheLocation, "AssetBundleCacher", AssetId));
}
@@ -269,6 +268,37 @@ namespace VRCX
}
}
public void SweepCache(string cacheDir)
{
var cachePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"Low\VRChat\VRChat\Cache-WindowsPlayer";
if (cacheDir != String.Empty && Directory.Exists(cacheDir))
cachePath = Path.Combine(cacheDir, @"Cache-WindowsPlayer");
if (!Directory.Exists(cachePath))
return;
var directories = new DirectoryInfo(cachePath);
DirectoryInfo[] cacheDirectories = directories.GetDirectories();
foreach (DirectoryInfo cacheDirectory in cacheDirectories)
{
var VersionDirectories = cacheDirectory.GetDirectories().OrderBy(d => Convert.ToInt32(d.Name, 16));
int i = 0;
foreach (DirectoryInfo VersionDirectory in VersionDirectories)
{
i++;
if (VersionDirectory.GetDirectories().Length + VersionDirectory.GetFiles().Length == 0)
{
VersionDirectory.Delete();
}
else if (i < VersionDirectories.Count())
{
if (!File.Exists(Path.Combine(VersionDirectory.FullName, "__lock")))
VersionDirectory.Delete(true);
}
}
if (cacheDirectory.GetDirectories().Length + cacheDirectory.GetFiles().Length == 0)
cacheDirectory.Delete();
}
}
public long GetCacheSize(string cacheDir)
{
var cachePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"Low\VRChat\VRChat\Cache-WindowsPlayer";