 da2b2701e8
			
		
	
	da2b2701e8
	
	
	
		
			
			make it resilent against restarts/reloads remove all user interaction for resource gathering compute hashes on first time file resolving and on updates of said file on resolving
		
			
				
	
	
		
			50 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			50 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System;
 | |
| using System.IO;
 | |
| using Microsoft.EntityFrameworkCore;
 | |
| using Microsoft.EntityFrameworkCore.Metadata;
 | |
| 
 | |
| #nullable disable
 | |
| 
 | |
| namespace MareSynchronos.FileCacheDB
 | |
| {
 | |
|     public partial class FileCacheContext : DbContext
 | |
|     {
 | |
|         public FileCacheContext()
 | |
|         {
 | |
|             Database.EnsureCreated();
 | |
|         }
 | |
| 
 | |
|         public FileCacheContext(DbContextOptions<FileCacheContext> options)
 | |
|             : base(options)
 | |
|         {
 | |
|         }
 | |
| 
 | |
|         public virtual DbSet<FileCache> FileCaches { get; set; }
 | |
| 
 | |
|         protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 | |
|         {
 | |
|             if (!optionsBuilder.IsConfigured)
 | |
|             {
 | |
|                 string dbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "XIVLauncher", "pluginConfigs", "FileCacheDebug.db");
 | |
|                 optionsBuilder.UseSqlite("Data Source=" + dbPath);
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         protected override void OnModelCreating(ModelBuilder modelBuilder)
 | |
|         {
 | |
|             modelBuilder.Entity<FileCache>(entity =>
 | |
|             {
 | |
|                 entity.HasKey(e => new { e.Hash, e.Filepath });
 | |
| 
 | |
|                 entity.ToTable("FileCache");
 | |
| 
 | |
|                 entity.Property(c => c.Version).HasDefaultValue(0).IsRowVersion();
 | |
|             });
 | |
| 
 | |
|             OnModelCreatingPartial(modelBuilder);
 | |
|         }
 | |
| 
 | |
|         partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
 | |
|     }
 | |
| }
 |