Skip to content

Commit

Permalink
Fix manage cache, OnPlayerLeft notification
Browse files Browse the repository at this point in the history
  • Loading branch information
Natsumi-sama committed Nov 22, 2024
1 parent cf0fc37 commit 26226e7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
12 changes: 9 additions & 3 deletions Dotnet/AssetBundleCacher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// For a copy, see <https://opensource.org/licenses/MIT>.

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Security.Cryptography;
Expand Down Expand Up @@ -276,17 +277,19 @@ public void DeleteAllCache()
/// <summary>
/// Removes empty directories from the VRChat cache directory and deletes old versions of cached asset bundles.
/// </summary>
public void SweepCache()
public List<string> SweepCache()
{
var output = new List<string>();
var cachePath = GetVRChatCacheLocation();
if (!Directory.Exists(cachePath))
return;
return output;
var directories = new DirectoryInfo(cachePath);
var cacheDirectories = directories.GetDirectories();
foreach (var cacheDirectory in cacheDirectories)
{
// var versionDirectories = cacheDirectory.GetDirectories().OrderBy(d => ReverseHexToDecimal(d.Name)).ToArray();
var versionDirectories =
cacheDirectory.GetDirectories().OrderBy(d => ReverseHexToDecimal(d.Name)).ToArray();
cacheDirectory.GetDirectories().OrderBy(d => d.LastWriteTime).ToArray();
for (var index = 0; index < versionDirectories.Length; index++)
{
var versionDirectory = versionDirectories[index];
Expand All @@ -303,11 +306,14 @@ public void SweepCache()
continue; // skip locked version

versionDirectory.Delete(true);
output.Add($"{cacheDirectory.Name}\\{versionDirectory.Name}");
}

if (cacheDirectory.GetDirectories().Length + cacheDirectory.GetFiles().Length == 0)
cacheDirectory.Delete(); // delete empty directory
}

return output;
}

/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion Dotnet/LogWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,9 @@ private bool ParseLogLocationDestination(FileInfo fileInfo, LogContext logContex
// 2021.09.02 00:02:12 Log - [Behaviour] Destination set: wrld_4432ea9b-729c-46e3-8eaf-846aa0a37fdd:15609~private(usr_032383a7-748c-4fb2-94e4-bcb928e5de6b)~nonce(72CC87D420C1D49AEFFBEE8824C84B2DF0E38678E840661E)
// 2021.09.02 00:49:15 Log - [Behaviour] Destination fetching: wrld_4432ea9b-729c-46e3-8eaf-846aa0a37fdd
// 2022.08.13 18:57:00 Log - [Behaviour] OnLeftRoom
// 2024.11.22 15:32:28 Log - [Behaviour] Successfully left room

if (line.Contains("[Behaviour] OnLeftRoom"))
if (line.Contains("[Behaviour] Successfully left room"))
{
AppendLog(new[]
{
Expand Down
10 changes: 8 additions & 2 deletions html/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4673,7 +4673,9 @@ speechSynthesis.getVoices();
this.updateOnlineFriendCoutner();
}
ctx.state = newState;
ctx.name = ref.displayName;
if (ref?.displayName) {
ctx.name = ref.displayName;
}
ctx.isVIP = isVIP;
};

Expand Down Expand Up @@ -5525,6 +5527,9 @@ speechSynthesis.getVoices();
`${ref.displayName} GPS ${previousLocation} -> ${newLocation}`
);
}
if (previousLocation === 'offline') {
previousLocation = '';
}
if (!previousLocation) {
// no previous location
if ($app.debugFriendState) {
Expand Down Expand Up @@ -16726,7 +16731,8 @@ speechSynthesis.getVoices();
};

$app.methods.sweepVRChatCache = async function () {
await AssetBundleCacher.SweepCache();
var output = await AssetBundleCacher.SweepCache();
console.log('SweepCache', output);
if (this.VRChatConfigDialog.visible) {
this.getVRChatCacheSize();
}
Expand Down

0 comments on commit 26226e7

Please sign in to comment.