⏪ Rollback some changes in drive
This commit is contained in:
@@ -27,7 +27,6 @@ public class AppDatabase(
|
|||||||
public DbSet<SnCloudFileIndex> FileIndexes { get; set; }
|
public DbSet<SnCloudFileIndex> FileIndexes { get; set; }
|
||||||
|
|
||||||
public DbSet<PersistentTask> Tasks { get; set; } = null!;
|
public DbSet<PersistentTask> Tasks { get; set; } = null!;
|
||||||
public DbSet<PersistentUploadTask> UploadTasks { get; set; } = null!; // Backward compatibility
|
|
||||||
|
|
||||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
{
|
{
|
||||||
@@ -42,18 +41,6 @@ public class AppDatabase(
|
|||||||
base.OnConfiguring(optionsBuilder);
|
base.OnConfiguring(optionsBuilder);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ConfigureOptions(IServiceProvider serviceProvider, DbContextOptionsBuilder optionsBuilder)
|
|
||||||
{
|
|
||||||
var configuration = serviceProvider.GetRequiredService<IConfiguration>();
|
|
||||||
optionsBuilder.UseNpgsql(
|
|
||||||
configuration.GetConnectionString("App"),
|
|
||||||
opt => opt
|
|
||||||
.ConfigureDataSource(optSource => optSource.EnableDynamicJson())
|
|
||||||
.UseQuerySplittingBehavior(QuerySplittingBehavior.SplitQuery)
|
|
||||||
.UseNodaTime()
|
|
||||||
).UseSnakeCaseNamingConvention();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
base.OnModelCreating(modelBuilder);
|
base.OnModelCreating(modelBuilder);
|
||||||
|
|||||||
@@ -9,58 +9,61 @@ namespace DysonNetwork.Drive.Startup;
|
|||||||
|
|
||||||
public static class ServiceCollectionExtensions
|
public static class ServiceCollectionExtensions
|
||||||
{
|
{
|
||||||
public static IServiceCollection AddAppServices(this IServiceCollection services, IConfiguration configuration)
|
extension(IServiceCollection services)
|
||||||
{
|
{
|
||||||
services.AddDbContextPool<AppDatabase>(AppDatabase.ConfigureOptions);
|
public IServiceCollection AddAppServices(IConfiguration configuration)
|
||||||
services.AddHttpContextAccessor();
|
|
||||||
|
|
||||||
services.AddHttpClient();
|
|
||||||
|
|
||||||
// Register gRPC services
|
|
||||||
services.AddGrpc(options =>
|
|
||||||
{
|
{
|
||||||
options.EnableDetailedErrors = true; // Will be adjusted in Program.cs
|
services.AddDbContext<AppDatabase>();
|
||||||
options.MaxReceiveMessageSize = 16 * 1024 * 1024; // 16MB
|
services.AddHttpContextAccessor();
|
||||||
options.MaxSendMessageSize = 16 * 1024 * 1024; // 16MB
|
|
||||||
});
|
|
||||||
services.AddGrpcReflection();
|
|
||||||
|
|
||||||
services.AddControllers().AddJsonOptions(options =>
|
services.AddHttpClient();
|
||||||
|
|
||||||
|
// Register gRPC services
|
||||||
|
services.AddGrpc(options =>
|
||||||
|
{
|
||||||
|
options.EnableDetailedErrors = true; // Will be adjusted in Program.cs
|
||||||
|
options.MaxReceiveMessageSize = 16 * 1024 * 1024; // 16MB
|
||||||
|
options.MaxSendMessageSize = 16 * 1024 * 1024; // 16MB
|
||||||
|
});
|
||||||
|
services.AddGrpcReflection();
|
||||||
|
|
||||||
|
services.AddControllers().AddJsonOptions(options =>
|
||||||
|
{
|
||||||
|
options.JsonSerializerOptions.NumberHandling = JsonNumberHandling.AllowNamedFloatingPointLiterals;
|
||||||
|
options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower;
|
||||||
|
options.JsonSerializerOptions.DictionaryKeyPolicy = JsonNamingPolicy.SnakeCaseLower;
|
||||||
|
|
||||||
|
options.JsonSerializerOptions.ConfigureForNodaTime(DateTimeZoneProviders.Tzdb);
|
||||||
|
});
|
||||||
|
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IServiceCollection AddAppAuthentication()
|
||||||
{
|
{
|
||||||
options.JsonSerializerOptions.NumberHandling = JsonNumberHandling.AllowNamedFloatingPointLiterals;
|
services.AddAuthorization();
|
||||||
options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower;
|
return services;
|
||||||
options.JsonSerializerOptions.DictionaryKeyPolicy = JsonNamingPolicy.SnakeCaseLower;
|
}
|
||||||
|
|
||||||
options.JsonSerializerOptions.ConfigureForNodaTime(DateTimeZoneProviders.Tzdb);
|
public IServiceCollection AddAppFlushHandlers()
|
||||||
});
|
{
|
||||||
|
services.AddSingleton<FlushBufferService>();
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IServiceCollection AddAppAuthentication(this IServiceCollection services)
|
public IServiceCollection AddAppBusinessServices()
|
||||||
{
|
{
|
||||||
services.AddAuthorization();
|
services.AddScoped<Storage.FileService>();
|
||||||
return services;
|
services.AddScoped<Storage.FileReferenceService>();
|
||||||
}
|
services.AddScoped<Storage.PersistentTaskService>();
|
||||||
|
services.AddScoped<FileIndexService>();
|
||||||
|
services.AddScoped<Billing.UsageService>();
|
||||||
|
services.AddScoped<Billing.QuotaService>();
|
||||||
|
|
||||||
public static IServiceCollection AddAppFlushHandlers(this IServiceCollection services)
|
services.AddHostedService<BroadcastEventHandler>();
|
||||||
{
|
|
||||||
services.AddSingleton<FlushBufferService>();
|
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IServiceCollection AddAppBusinessServices(this IServiceCollection services)
|
|
||||||
{
|
|
||||||
services.AddScoped<Storage.FileService>();
|
|
||||||
services.AddScoped<Storage.FileReferenceService>();
|
|
||||||
services.AddScoped<Storage.PersistentTaskService>();
|
|
||||||
services.AddScoped<FileIndexService>();
|
|
||||||
services.AddScoped<Billing.UsageService>();
|
|
||||||
services.AddScoped<Billing.QuotaService>();
|
|
||||||
|
|
||||||
services.AddHostedService<BroadcastEventHandler>();
|
|
||||||
|
|
||||||
return services;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user