mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-06 22:46:06 +02:00
Misc fixes
This commit is contained in:
@@ -116,14 +116,11 @@ public partial class AppApi
|
||||
var path = GetVRChatPhotosLocation();
|
||||
if (!Directory.Exists(path))
|
||||
return null;
|
||||
|
||||
var lastDirectory = Directory.GetDirectories(path).OrderByDescending(Directory.GetCreationTime).FirstOrDefault();
|
||||
if (lastDirectory == null)
|
||||
return null;
|
||||
|
||||
var lastScreenshot = Directory.GetFiles(lastDirectory, "*.png").OrderByDescending(File.GetCreationTime).FirstOrDefault();
|
||||
if (lastScreenshot == null)
|
||||
return null;
|
||||
|
||||
// exclude folder names that contain "Prints" or "Stickers"
|
||||
var imageFiles = Directory.GetFiles(path, "*.png", SearchOption.AllDirectories)
|
||||
.Where(x => !Regex.IsMatch(x, @"\\Prints\\|\\Stickers\\", RegexOptions.IgnoreCase));
|
||||
var lastScreenshot = imageFiles.OrderByDescending(Directory.GetCreationTime).FirstOrDefault();
|
||||
|
||||
return lastScreenshot;
|
||||
}
|
||||
|
||||
@@ -76,16 +76,17 @@ namespace VRCX
|
||||
if (metadata == null || metadata.Error != null)
|
||||
{
|
||||
addToCache.Add(dbEntry);
|
||||
metadataCache.Add(file, null);
|
||||
metadataCache.TryAdd(file, null);
|
||||
continue;
|
||||
}
|
||||
|
||||
dbEntry.Metadata = JsonConvert.SerializeObject(metadata);
|
||||
addToCache.Add(dbEntry);
|
||||
metadataCache.Add(file, metadata);
|
||||
metadataCache.TryAdd(file, metadata);
|
||||
}
|
||||
|
||||
if (metadata == null) continue;
|
||||
if (metadata == null)
|
||||
continue;
|
||||
|
||||
switch (searchType)
|
||||
{
|
||||
@@ -121,18 +122,13 @@ namespace VRCX
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves metadata from a PNG screenshot file and attempts to parse it.
|
||||
/// </summary>
|
||||
/// <param name="path">The path to the PNG screenshot file.</param>
|
||||
/// <returns>A JObject containing the metadata or null if no metadata was found.</returns>
|
||||
public static ScreenshotMetadata GetScreenshotMetadata(string path, bool includeJSON = false)
|
||||
public static ScreenshotMetadata? GetScreenshotMetadata(string path, bool includeJSON = false)
|
||||
{
|
||||
// Early return if file doesn't exist, or isn't a PNG(Check both extension and file header)
|
||||
if (!File.Exists(path) || !path.EndsWith(".png") || !IsPNGFile(path))
|
||||
return null;
|
||||
|
||||
///if (metadataCache.TryGetValue(path, out var cachedMetadata))
|
||||
// if (metadataCache.TryGetValue(path, out var cachedMetadata))
|
||||
// return cachedMetadata;
|
||||
|
||||
string metadataString;
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace VRCX
|
||||
/// Any error that occurred while parsing the file. This being true implies nothing else is set.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
internal string Error;
|
||||
internal string? Error;
|
||||
|
||||
[JsonIgnore]
|
||||
internal string JSON;
|
||||
|
||||
Reference in New Issue
Block a user