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)
{
logger.Error(e);
return defaultPath;
logger.Error($"Error reading VRChat config file for cache location: {e}");
}
return defaultPath;
}
public override string GetVRChatPhotosLocation()
{
var json = ReadConfigFile();
if (!string.IsNullOrEmpty(json))
var defaultPath = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "VRChat");
try
{
var obj = JsonConvert.DeserializeObject<JObject>(json);
if (obj["picture_output_folder"] != null)
{
var photosDir = (string)obj["picture_output_folder"];
if (!string.IsNullOrEmpty(photosDir) && Directory.Exists(photosDir))
{
return photosDir;
}
}
}
var json = ReadConfigFile();
if (string.IsNullOrEmpty(json))
return defaultPath;
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 = "")