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.IO.Compression;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Net.Http;
using System.Reflection; using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading.Tasks; using System.Threading.Tasks;
using Hangfire;
using Hangfire.Console; using Hangfire.Console;
using Hangfire.Server; using Hangfire.Server;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
@ -52,6 +54,7 @@ namespace Ombi.Schedule.Jobs.Ombi
} }
[AutomaticRetry(Attempts = 1)]
public async Task Update(PerformContext c) public async Task Update(PerformContext c)
{ {
Ctx = 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 Hangfire;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
@ -20,7 +19,6 @@ using Ombi.Core.Claims;
using Ombi.Core.Helpers; using Ombi.Core.Helpers;
using Ombi.Core.Models.UI; using Ombi.Core.Models.UI;
using Ombi.Core.Settings; using Ombi.Core.Settings;
using Ombi.Helpers;
using Ombi.Models; using Ombi.Models;
using Ombi.Models.Identity; using Ombi.Models.Identity;
using Ombi.Notifications; using Ombi.Notifications;
@ -29,7 +27,6 @@ using Ombi.Schedule.Jobs.Ombi;
using Ombi.Settings.Settings.Models; using Ombi.Settings.Settings.Models;
using Ombi.Settings.Settings.Models.Notifications; using Ombi.Settings.Settings.Models.Notifications;
using Ombi.Store.Entities; using Ombi.Store.Entities;
using Ombi.Store.Repository;
using OmbiIdentityResult = Ombi.Models.Identity.IdentityResult; using OmbiIdentityResult = Ombi.Models.Identity.IdentityResult;
namespace Ombi.Controllers namespace Ombi.Controllers

@ -58,7 +58,7 @@ namespace Ombi
.MinimumLevel.Information() .MinimumLevel.Information()
.WriteTo.RollingFile(Path.Combine(env.ContentRootPath, "Logs", "log-{Date}.txt")) .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(); .CreateLogger();
} }
else else
@ -67,7 +67,7 @@ namespace Ombi
.MinimumLevel.Information() .MinimumLevel.Information()
.WriteTo.RollingFile(Path.Combine(StoragePath.StoragePath, "Logs", "log-{Date}.txt")) .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(); .CreateLogger();
} }
Log.Logger = config; Log.Logger = config;
@ -105,7 +105,7 @@ namespace Ombi
options.Password.RequireLowercase = false; options.Password.RequireLowercase = false;
options.Password.RequireNonAlphanumeric = false; options.Password.RequireNonAlphanumeric = false;
options.Password.RequireUppercase = false; options.Password.RequireUppercase = false;
options.User.AllowedUserNameCharacters =string.Empty; options.User.AllowedUserNameCharacters = string.Empty;
}); });
services.AddMemoryCache(); services.AddMemoryCache();
@ -173,12 +173,13 @@ namespace Ombi
app.UsePathBase(settings.BaseUrl); 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", app.UseHangfireDashboard(settings.BaseUrl.HasValue() ? $"{settings.BaseUrl}/hangfire" : "/hangfire",
new DashboardOptions new DashboardOptions
{ {
Authorization = new[] {new HangfireAuthorizationFilter()} Authorization = new[] { new HangfireAuthorizationFilter() }
}); });
GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute { Attempts = 3 });
// Setup the scheduler // Setup the scheduler
var jobSetup = app.ApplicationServices.GetService<IJobSetup>(); var jobSetup = app.ApplicationServices.GetService<IJobSetup>();
@ -237,7 +238,7 @@ namespace Ombi
else else
{ {
var identity = new GenericIdentity("API"); var identity = new GenericIdentity("API");
var principal = new GenericPrincipal(identity, new[] {"Admin", "ApiUser"}); var principal = new GenericPrincipal(identity, new[] { "Admin", "ApiUser" });
context.User = principal; context.User = principal;
await next(); await next();
} }

Loading…
Cancel
Save