[Refactor] Use collection expression.

This commit is contained in:
2025-07-08 23:10:49 +01:00
parent 31325d573b
commit 19bb166ed3
3 changed files with 11 additions and 11 deletions

View File

@@ -25,9 +25,9 @@ public sealed class Fuse : FileSystem
public Fuse(Vfs vfs)
{
_directoryCache = new ConcurrentDictionary<long, List<DirectoryEntry>>();
_directoryCache = [];
_lastHandle = 0;
_fileStatHandleCache = new ConcurrentDictionary<long, Stat>();
_fileStatHandleCache = [];
Name = "romrepomgrfs";
_vfs = vfs;
}

View File

@@ -197,7 +197,7 @@ public class Vfs : IDisposable
if(cachedMachines != null) return cachedMachines;
cachedMachines = new ConcurrentDictionary<string, CachedMachine>();
cachedMachines = [];
using var ctx = Context.Create(Settings.Settings.Current.DatabasePath);
@@ -233,7 +233,7 @@ public class Vfs : IDisposable
using var ctx = Context.Create(Settings.Settings.Current.DatabasePath);
cachedMachineFiles = new ConcurrentDictionary<string, CachedFile>();
cachedMachineFiles = [];
foreach(FileByMachine machineFile in ctx.FilesByMachines.Where(fbm => fbm.Machine.Id == id && fbm.File.IsInRepo)
.Include(fileByMachine => fileByMachine.File))
@@ -269,7 +269,7 @@ public class Vfs : IDisposable
using var ctx = Context.Create(Settings.Settings.Current.DatabasePath);
cachedMachineDisks = new ConcurrentDictionary<string, CachedDisk>();
cachedMachineDisks = [];
foreach(DiskByMachine machineDisk in ctx.DisksByMachines
.Where(dbm => dbm.Machine.Id == id &&
@@ -303,7 +303,7 @@ public class Vfs : IDisposable
using var ctx = Context.Create(Settings.Settings.Current.DatabasePath);
cachedMachineMedias = new ConcurrentDictionary<string, CachedMedia>();
cachedMachineMedias = [];
foreach(MediaByMachine machineMedia in ctx.MediasByMachines
.Where(mbm => mbm.Machine.Id == id &&

View File

@@ -514,35 +514,35 @@ public sealed class DatImporter
? ctx.Disks
.FromSqlRaw($"SELECT DISTINCT f.* FROM Disks AS f, [{tmpDiskMd5Table}] AS t WHERE f.Md5 = t.Md5")
.ToDictionary(f => f.Md5)
: new Dictionary<string, DbDisk>();
: [];
Dictionary<string, DbDisk> pendingDisksBySha1 =
disksHaveSha1
? ctx.Disks
.FromSqlRaw($"SELECT DISTINCT f.* FROM Disks AS f, [{tmpDiskSha1Table}] AS t WHERE f.Sha1 = t.Sha1")
.ToDictionary(f => f.Sha1)
: new Dictionary<string, DbDisk>();
: [];
Dictionary<string, DbMedia> pendingMediasByMd5 =
mediasHaveMd5
? ctx.Medias
.FromSqlRaw($"SELECT DISTINCT f.* FROM Medias AS f, [{tmpMediaMd5Table}] AS t WHERE f.Md5 = t.Md5")
.ToDictionary(f => f.Md5)
: new Dictionary<string, DbMedia>();
: [];
Dictionary<string, DbMedia> pendingMediasBySha1 =
mediasHaveSha1
? ctx.Medias
.FromSqlRaw($"SELECT DISTINCT f.* FROM Medias AS f, [{tmpMediaSha1Table}] AS t WHERE f.Sha1 = t.Sha1")
.ToDictionary(f => f.Sha1)
: new Dictionary<string, DbMedia>();
: [];
Dictionary<string, DbMedia> pendingMediasBySha256 =
mediasHaveSha256
? ctx.Medias
.FromSqlRaw($"SELECT DISTINCT f.* FROM Medias AS f, [{tmpMediaSha256Table}] AS t WHERE f.Sha256 = t.Sha256")
.ToDictionary(f => f.Sha256)
: new Dictionary<string, DbMedia>();
: [];
var pendingFilesByCrc = new Dictionary<string, DbFile>();
var pendingFilesByMd5 = new Dictionary<string, DbFile>();