Changed the way we download the .zip files in the auto updater #1460 This might make a difference to the permissions issue. but not 100% sure.

Also lowered the retrying of jobs to default to 5, but updater to retry only once.
pull/1614/head
Jamie.Rees 7 years ago
parent ec57c5f0cd
commit 247d708e7a

@ -5,9 +5,11 @@ using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Hangfire;
using Hangfire.Console;
using Hangfire.Server;
using Microsoft.Extensions.Logging;
@ -52,6 +54,7 @@ namespace Ombi.Schedule.Jobs.Ombi
}
[AutomaticRetry(Attempts = 1)]
public async Task Update(PerformContext c)
{
Ctx = c;
@ -217,11 +220,23 @@ namespace Ombi.Schedule.Jobs.Ombi
}
}
public static async Task DownloadAsync(string requestUri, string filename, PerformContext ctx)
public async Task DownloadAsync(string requestUri, string filename, PerformContext ctx)
{
using (var client = new WebClient())
Logger.LogDebug("Starting the DownloadAsync");
using (var client = new HttpClient())
{
await client.DownloadFileTaskAsync(requestUri, filename);
using (var result = await client.GetAsync(requestUri))
{
if (result.IsSuccessStatusCode)
{
var contentStream = await result.Content.ReadAsStreamAsync();
using (var stream =
new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.None))
{
await contentStream.CopyToAsync(stream);
}
}
}
}
}
}

@ -8,7 +8,6 @@ using AutoMapper;
using Hangfire;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
@ -20,7 +19,6 @@ using Ombi.Core.Claims;
using Ombi.Core.Helpers;
using Ombi.Core.Models.UI;
using Ombi.Core.Settings;
using Ombi.Helpers;
using Ombi.Models;
using Ombi.Models.Identity;
using Ombi.Notifications;
@ -29,7 +27,6 @@ using Ombi.Schedule.Jobs.Ombi;
using Ombi.Settings.Settings.Models;
using Ombi.Settings.Settings.Models.Notifications;
using Ombi.Store.Entities;
using Ombi.Store.Repository;
using OmbiIdentityResult = Ombi.Models.Identity.IdentityResult;
namespace Ombi.Controllers

@ -58,7 +58,7 @@ namespace Ombi
.MinimumLevel.Information()
.WriteTo.RollingFile(Path.Combine(env.ContentRootPath, "Logs", "log-{Date}.txt"))
.WriteTo.SQLite("Ombi.db", "Logs", LogEventLevel.Information)
.WriteTo.SQLite("Ombi.db", "Logs", LogEventLevel.Debug)
.CreateLogger();
}
else
@ -67,7 +67,7 @@ namespace Ombi
.MinimumLevel.Information()
.WriteTo.RollingFile(Path.Combine(StoragePath.StoragePath, "Logs", "log-{Date}.txt"))
.WriteTo.SQLite(Path.Combine(StoragePath.StoragePath, "Ombi.db"), "Logs", LogEventLevel.Information)
.WriteTo.SQLite(Path.Combine(StoragePath.StoragePath, "Ombi.db"), "Logs", LogEventLevel.Debug)
.CreateLogger();
}
Log.Logger = config;
@ -92,7 +92,7 @@ namespace Ombi
// Add framework services.
services.AddDbContext<OmbiContext>();
services.AddIdentity<OmbiUser, IdentityRole>()
.AddEntityFrameworkStores<OmbiContext>()
.AddDefaultTokenProviders()
@ -105,9 +105,9 @@ namespace Ombi
options.Password.RequireLowercase = false;
options.Password.RequireNonAlphanumeric = false;
options.Password.RequireUppercase = false;
options.User.AllowedUserNameCharacters =string.Empty;
options.User.AllowedUserNameCharacters = string.Empty;
});
services.AddMemoryCache();
services.AddJwtAuthentication(Configuration);
@ -131,7 +131,7 @@ namespace Ombi
i.StoragePath = string.Empty;
}
var sqliteStorage = $"Data Source={Path.Combine(i.StoragePath, "Ombi.db")};";
services.AddHangfire(x =>
{
x.UseSQLiteStorage(sqliteStorage);
@ -173,12 +173,13 @@ namespace Ombi
app.UsePathBase(settings.BaseUrl);
}
app.UseHangfireServer(new BackgroundJobServerOptions{WorkerCount = 1});
app.UseHangfireServer(new BackgroundJobServerOptions { WorkerCount = 1 });
app.UseHangfireDashboard(settings.BaseUrl.HasValue() ? $"{settings.BaseUrl}/hangfire" : "/hangfire",
new DashboardOptions
{
Authorization = new[] {new HangfireAuthorizationFilter()}
Authorization = new[] { new HangfireAuthorizationFilter() }
});
GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute { Attempts = 3 });
// Setup the scheduler
var jobSetup = app.ApplicationServices.GetService<IJobSetup>();
@ -201,7 +202,7 @@ namespace Ombi
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
c.ShowJsonEditor();
});
app.UseMvc(routes =>
{
routes.MapRoute(
@ -237,7 +238,7 @@ namespace Ombi
else
{
var identity = new GenericIdentity("API");
var principal = new GenericPrincipal(identity, new[] {"Admin", "ApiUser"});
var principal = new GenericPrincipal(identity, new[] { "Admin", "ApiUser" });
context.User = principal;
await next();
}

Loading…
Cancel
Save