Browse Source

MK2: meta json prop

HOME 7 months ago
parent
commit
8b2c6ec3b4

+ 12 - 0
FNZCM2/FNZCM2.Abstractions/Models/Caches/CacheModel.cs

@@ -0,0 +1,12 @@
+using System.Text.Json.Serialization;
+using FNZCM2.Abstractions.Models.Fs;
+using FNZCM2.Abstractions.Models.Metadata;
+
+namespace FNZCM2.Abstractions.Models.Caches;
+
+public class CacheModel
+{
+    [JsonPropertyName("f")] public required IReadOnlyList<FileEntry> Files { get; init; }
+    [JsonPropertyName("d")] public required IReadOnlyList<FolderEntry> Folders { get; init; }
+    [JsonPropertyName("m")] public required IReadOnlyList<FileMetaEntry> Meta { get; init; }
+}

+ 7 - 11
FNZCM2/FNZCM2.Abstractions/Models/Fs/FileEntry.cs

@@ -1,21 +1,17 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using System.Diagnostics;
+using System.Text.Json.Serialization;
 
 namespace FNZCM2.Abstractions.Models.Fs;
 
 [DebuggerDisplay("F {Id} # {Name} # {Size}")]
 public class FileEntry : IFsEntry
 {
-    public required long Id { get; init; }
+    [JsonPropertyName("i")] public required long Id { get; init; }
 
     /// <summary> zero for root </summary>
-    public required long FolderId { get; init; }
+    [JsonPropertyName("f")] public required long FolderId { get; init; }
 
-    public required string Name { get; init; }
-    public required long Size { get; init; }
-    public required DateTimeOffset LastChangedTime { get; init; }
+    [JsonPropertyName("n")] public required string Name { get; init; }
+    [JsonPropertyName("s")] public required long Size { get; init; }
+    [JsonPropertyName("t")] public required DateTimeOffset LastChangedTime { get; init; }
 }

+ 7 - 6
FNZCM2/FNZCM2.Abstractions/Models/Fs/FolderEntry.cs

@@ -1,15 +1,16 @@
 using System.Diagnostics;
+using System.Text.Json.Serialization;
 
 namespace FNZCM2.Abstractions.Models.Fs;
 
 [DebuggerDisplay("D {Id} # {Name}")]
 public class FolderEntry : IFsEntry
 {
-    public required long Id { get; init; }
-    
+    [JsonPropertyName("i")] public required long Id { get; init; }
+
     /// <summary> zero for root </summary>
-    public required long FolderId { get; init; }
+    [JsonPropertyName("f")] public required long FolderId { get; init; }
 
-    public required string Name { get; init; }
-    public required DateTimeOffset LastChangedTime { get; init; }
-}
+    [JsonPropertyName("n")] public required string Name { get; init; }
+    [JsonPropertyName("t")] public required DateTimeOffset LastChangedTime { get; init; }
+}

+ 2 - 2
FNZCM2/FNZCM2.Abstractions/Models/Metadata/AudioInfo.cs

@@ -6,6 +6,6 @@ namespace FNZCM2.Abstractions.Models.Metadata;
 public class AudioInfo
 {
     [JsonPropertyName("f")] public required AVSampleFormat SampleFormat { get; init; }
-    [JsonPropertyName("s")] public required int? SampleRate { get; init; }
-    [JsonPropertyName("b")] public required int? BitPerSample { get; init; }
+    [JsonPropertyName("r")] public required int? SampleRate { get; init; }
+    [JsonPropertyName("d")] public required int? BitPerSample { get; init; }
 }

+ 32 - 32
FNZCM2/FNZCM2.Abstractions/Utility/FolderScan.cs

@@ -3,13 +3,13 @@ using FNZCM2.Abstractions.Models.Fs;
 
 namespace FNZCM2.Abstractions.Utility;
 
-using FSE = (bool isDir, string path, long size, System.DateTimeOffset lastWrited);
+using FSE = (bool isDir, string path, long size, DateTimeOffset lastWrited);
 
 public static class FolderScan
 {
     public static FolderScanResult Scan(string folderPath)
     {
-        List<IFsEntry> allEntries = new();
+        //List<IFsEntry> allEntries = new();
         List<FolderEntry> allFolders = new();
         List<FileEntry> allFiles = new();
 
@@ -66,7 +66,7 @@ public static class FolderScan
                     LastChangedTime = e.lastWrited,
                 };
 
-                allEntries.Add(folderEntry);
+                //allEntries.Add(folderEntry);
                 allFolders.Add(folderEntry);
             }
             else
@@ -80,37 +80,37 @@ public static class FolderScan
                     Size = e.size,
                 };
 
-                allEntries.Add(fileEntry);
+                //allEntries.Add(fileEntry);
                 allFiles.Add(fileEntry);
             }
         }
 
-        var allById = allEntries.ToDictionary(e => e.Id);
-        var allInFolder = allEntries
-            .GroupBy(e => e.FolderId)
-            .ToDictionary(g => g.Key, g => (IReadOnlyList<IFsEntry>)g.ToArray());
+        //var allById = allEntries.ToDictionary(e => e.Id);
+        //var allInFolder = allEntries
+        //    .GroupBy(e => e.FolderId)
+        //    .ToDictionary(g => g.Key, g => (IReadOnlyList<IFsEntry>)g.ToArray());
 
-        var folderById = allFolders.ToDictionary(f => f.Id);
-        var foldersInFolder = allFolders
-            .GroupBy(f => f.FolderId)
-            .ToDictionary(g => g.Key, g => (IReadOnlyList<FolderEntry>)g.ToArray());
+        //var folderById = allFolders.ToDictionary(f => f.Id);
+        //var foldersInFolder = allFolders
+        //    .GroupBy(f => f.FolderId)
+        //    .ToDictionary(g => g.Key, g => (IReadOnlyList<FolderEntry>)g.ToArray());
 
-        var fileById = allFiles.ToDictionary(f => f.Id);
-        var filesInFolder = allFiles
-            .GroupBy(f => f.FolderId)
-            .ToDictionary(g => g.Key, g => (IReadOnlyList<FileEntry>)g.ToArray());
+        //var fileById = allFiles.ToDictionary(f => f.Id);
+        //var filesInFolder = allFiles
+        //    .GroupBy(f => f.FolderId)
+        //    .ToDictionary(g => g.Key, g => (IReadOnlyList<FileEntry>)g.ToArray());
 
         return new FolderScanResult
         {
-            All = allEntries,
-            AllById = allById,
-            AllInFolder = allInFolder,
-            Folders = allFolders,
-            FolderById = folderById,
-            FoldersInFolder = foldersInFolder,
-            Files = allFiles,
-            FileById = fileById,
-            FilesInFolder = filesInFolder,
+            //All = allEntries,
+            //AllById = allById,
+            //AllInFolder = allInFolder,
+            Folders = allFolders.ToArray(),
+            //FolderById = folderById,
+            //FoldersInFolder = foldersInFolder,
+            Files = allFiles.ToArray(),
+            //FileById = fileById,
+            //FilesInFolder = filesInFolder,
             //add folderPathToIdCache on demands
         };
     }
@@ -118,15 +118,15 @@ public static class FolderScan
 
 public class FolderScanResult
 {
-    public required IReadOnlyList<IFsEntry> All { get; init; }
-    public required IReadOnlyDictionary<long, IFsEntry> AllById { get; init; }
-    public required IReadOnlyDictionary<long, IReadOnlyList<IFsEntry>> AllInFolder { get; init; }
+    //public required IReadOnlyList<IFsEntry> All { get; init; }
+    //public required IReadOnlyDictionary<long, IFsEntry> AllById { get; init; }
+    //public required IReadOnlyDictionary<long, IReadOnlyList<IFsEntry>> AllInFolder { get; init; }
 
     public required IReadOnlyList<FolderEntry> Folders { get; init; }
-    public required IReadOnlyDictionary<long, FolderEntry> FolderById { get; init; }
-    public required IReadOnlyDictionary<long, IReadOnlyList<FolderEntry>> FoldersInFolder { get; init; }
+    //public required IReadOnlyDictionary<long, FolderEntry> FolderById { get; init; }
+    //public required IReadOnlyDictionary<long, IReadOnlyList<FolderEntry>> FoldersInFolder { get; init; }
 
     public required IReadOnlyList<FileEntry> Files { get; init; }
-    public required IReadOnlyDictionary<long, FileEntry> FileById { get; init; }
-    public required IReadOnlyDictionary<long, IReadOnlyList<FileEntry>> FilesInFolder { get; init; }
+    //public required IReadOnlyDictionary<long, FileEntry> FileById { get; init; }
+    //public required IReadOnlyDictionary<long, IReadOnlyList<FileEntry>> FilesInFolder { get; init; }
 }

+ 4 - 4
FNZCM2/FNZCM2.ProofOfConcept/PocFfMpegReader.cs

@@ -52,7 +52,7 @@ internal static class PocFfMpegReader
     {
         //choose a file to open
         var fse = new FileSystemEnumerable<FSE>(
-            "library",
+            "library-ajc",
             (ref FileSystemEntry p) => new(
                 p.IsDirectory,
                 p.ToFullPath(),
@@ -108,7 +108,7 @@ internal static class PocFfMpegReader
     {
         //choose a file to open
         var fse = new FileSystemEnumerable<FSE>(
-            "library",
+            "library-ajc",
             (ref FileSystemEntry p) => new(
                 p.IsDirectory,
                 p.ToFullPath(),
@@ -134,7 +134,7 @@ internal static class PocFfMpegReader
     {
         //choose a file to open
         var fse = new FileSystemEnumerable<FSE>(
-            "library",
+            "library-ajc",
             (ref FileSystemEntry p) => new(
                 p.IsDirectory,
                 p.ToFullPath(),
@@ -160,7 +160,7 @@ internal static class PocFfMpegReader
     {
         //choose a file to open
         var fse = new FileSystemEnumerable<FSE>(
-            "library",
+            "library-ajc",
             (ref FileSystemEntry p) => new(
                 p.IsDirectory,
                 p.ToFullPath(),