Handle error parsing scuffed config.json

This commit is contained in:
Natsumi
2025-05-27 02:02:55 +10:00
parent 9bd5c79a71
commit 78daeac736
3 changed files with 73 additions and 41 deletions
+22 -15
View File
@@ -44,28 +44,35 @@ namespace VRCX
} }
catch (Exception e) catch (Exception e)
{ {
logger.Error(e); logger.Error($"Error reading VRChat config file for cache location: {e}");
return defaultPath;
} }
return defaultPath;
} }
public override string GetVRChatPhotosLocation() public override string GetVRChatPhotosLocation()
{ {
var json = ReadConfigFile(); var defaultPath = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "VRChat");
if (!string.IsNullOrEmpty(json)) try
{ {
var obj = JsonConvert.DeserializeObject<JObject>(json); var json = ReadConfigFile();
if (obj["picture_output_folder"] != null) if (string.IsNullOrEmpty(json))
{ return defaultPath;
var photosDir = (string)obj["picture_output_folder"];
if (!string.IsNullOrEmpty(photosDir) && Directory.Exists(photosDir))
{
return photosDir;
}
}
}
return Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "VRChat"); var obj = JsonConvert.DeserializeObject<JObject>(json);
if (obj["picture_output_folder"] == null)
return defaultPath;
var photosDir = (string)obj["picture_output_folder"];
if (string.IsNullOrEmpty(photosDir) || !Directory.Exists(photosDir))
return defaultPath;
return photosDir;
}
catch (Exception e)
{
logger.Error($"Error reading VRChat config file for photos location: {e}");
}
return defaultPath;
} }
public override string GetUGCPhotoLocation(string path = "") public override string GetUGCPhotoLocation(string path = "")
+47 -27
View File
@@ -86,40 +86,58 @@ namespace VRCX
public override string GetVRChatCacheLocation() public override string GetVRChatCacheLocation()
{ {
var json = ReadConfigFile(); var defaultPath = Path.Join(GetVRChatAppDataLocation(), "Cache-WindowsPlayer");
if (!string.IsNullOrEmpty(json)) try
{ {
var obj = JsonConvert.DeserializeObject<JObject>(json); var json = ReadConfigFile();
if (obj["cache_directory"] != null) if (string.IsNullOrEmpty(json))
{ return defaultPath;
var cacheDir = (string)obj["cache_directory"];
if (!string.IsNullOrEmpty(cacheDir) && Directory.Exists(cacheDir))
{
return cacheDir;
}
}
}
return Path.Join(GetVRChatAppDataLocation(), "Cache-WindowsPlayer"); var obj = JsonConvert.DeserializeObject<JObject>(json);
if (obj["cache_directory"] == null)
return defaultPath;
var cacheDir = (string)obj["cache_directory"];
if (string.IsNullOrEmpty(cacheDir))
return defaultPath;
var cachePath = Path.Join(cacheDir, "Cache-WindowsPlayer");
if (!Directory.Exists(cacheDir))
return defaultPath;
return cachePath;
}
catch (Exception e)
{
logger.Error($"Error reading VRChat config file for cache location: {e}");
}
return defaultPath;
} }
public override string GetVRChatPhotosLocation() public override string GetVRChatPhotosLocation()
{ {
var json = ReadConfigFile(); var defaultPath = Path.Join(_vrcPrefixPath, "drive_c/users/steamuser/Pictures/VRChat");
if (!string.IsNullOrEmpty(json)) try
{ {
var obj = JsonConvert.DeserializeObject<JObject>(json); var json = ReadConfigFile();
if (obj["picture_output_folder"] != null) if (string.IsNullOrEmpty(json))
{ return defaultPath;
var photosDir = (string)obj["picture_output_folder"];
if (!string.IsNullOrEmpty(photosDir) && Directory.Exists(photosDir))
{
return photosDir;
}
}
}
return Path.Join(_vrcPrefixPath, "drive_c/users/steamuser/Pictures/VRChat"); var obj = JsonConvert.DeserializeObject<JObject>(json);
if (obj["picture_output_folder"] == null)
return defaultPath;
var photosDir = (string)obj["picture_output_folder"];
if (string.IsNullOrEmpty(photosDir) || !Directory.Exists(photosDir))
return defaultPath;
return photosDir;
}
catch (Exception e)
{
logger.Error($"Error reading VRChat config file for photos location: {e}");
}
return defaultPath;
} }
public override string GetUGCPhotoLocation(string path = "") public override string GetUGCPhotoLocation(string path = "")
@@ -263,7 +281,9 @@ namespace VRCX
} }
}; };
process.Start(); process.Start();
return; process.WaitForExit();
if (process.ExitCode == 0)
return;
} }
catch (Exception) catch (Exception)
{ {
+6 -1
View File
@@ -554,11 +554,16 @@ export default class extends baseClass {
} else if (contentType === 'world') { } else if (contentType === 'world') {
// hmm // hmm
} else if (contentType === 'created') { } else if (contentType === 'created') {
// on avatar upload // on avatar upload, might be gone now
} else if (contentType === 'avatargallery') { } else if (contentType === 'avatargallery') {
// on avatar gallery image upload // on avatar gallery image upload
} else if (contentType === 'invitePhoto') { } else if (contentType === 'invitePhoto') {
// on uploading invite photo // on uploading invite photo
} else if (!contentType) {
console.log(
'content-refresh without contentType',
content
);
} else { } else {
console.log( console.log(
'Unknown content-refresh type', 'Unknown content-refresh type',