Fixes the issue with non windows systems unable to unzip the tarball #1460

pull/1614/head
tidusjar 7 years ago
parent d05d76be4b
commit 7ce8036cab

@ -42,7 +42,6 @@ using Ombi.Schedule.Jobs.Emby;
using Ombi.Schedule.Jobs.Ombi;
using Ombi.Schedule.Jobs.Plex;
using Ombi.Schedule.Jobs.Sonarr;
using Ombi.Schedule.Ombi;
using Ombi.Store.Repository.Requests;
using PlexContentCacher = Ombi.Schedule.Jobs.Plex.PlexContentCacher;

@ -1,10 +1,10 @@
using Hangfire;
using Ombi.Schedule.Jobs;
using Ombi.Schedule.Jobs.Emby;
using Ombi.Schedule.Jobs.Ombi;
using Ombi.Schedule.Jobs.Plex;
using Ombi.Schedule.Jobs.Radarr;
using Ombi.Schedule.Jobs.Sonarr;
using Ombi.Schedule.Ombi;
namespace Ombi.Schedule
{

@ -1,7 +1,7 @@
using System.Threading.Tasks;
using Hangfire.Server;
namespace Ombi.Schedule.Ombi
namespace Ombi.Schedule.Jobs.Ombi
{
public interface IOmbiAutomaticUpdater
{

@ -16,8 +16,9 @@ using Ombi.Api.Service;
using Ombi.Api.Service.Models;
using Ombi.Core.Settings;
using Ombi.Helpers;
using Ombi.Schedule.Ombi;
using Ombi.Settings.Settings.Models;
using SharpCompress.Readers;
using SharpCompress.Readers.Tar;
namespace Ombi.Schedule.Jobs.Ombi
{
@ -44,11 +45,11 @@ namespace Ombi.Schedule.Jobs.Ombi
}
public async Task<bool> UpdateAvailable(string branch, string currentVersion)
{
var updates = await OmbiService.GetUpdates(branch);
var serverVersion = updates.UpdateVersionString;
return !serverVersion.Equals(currentVersion, StringComparison.CurrentCultureIgnoreCase);
var updates = await OmbiService.GetUpdates(branch);
var serverVersion = updates.UpdateVersionString;
return !serverVersion.Equals(currentVersion, StringComparison.CurrentCultureIgnoreCase);
}
public async Task Update(PerformContext c)
@ -153,21 +154,8 @@ namespace Ombi.Schedule.Jobs.Ombi
}
// Extract it
Ctx.WriteLine("Extracting ZIP");
using (var files = ZipFile.OpenRead(zipDir))
{
// Temp Path
Directory.CreateDirectory(tempPath);
foreach (var entry in files.Entries)
{
if (entry.FullName.Contains("/"))
{
var path = Path.GetDirectoryName(Path.Combine(tempPath, entry.FullName));
Directory.CreateDirectory(path);
}
Extract(zipDir, tempPath, extension);
entry.ExtractToFile(Path.Combine(tempPath, entry.FullName));
}
}
Ctx.WriteLine("Finished Extracting files");
Ctx.WriteLine("Starting the Ombi.Updater process");
var updaterExtension = string.Empty;
@ -197,6 +185,38 @@ namespace Ombi.Schedule.Jobs.Ombi
}
}
private void Extract(string zipDir, string tempPath, string osPlat)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
using (var files = ZipFile.OpenRead(zipDir))
{
// Temp Path
Directory.CreateDirectory(tempPath);
foreach (var entry in files.Entries)
{
if (entry.FullName.Contains("/"))
{
var path = Path.GetDirectoryName(Path.Combine(tempPath, entry.FullName));
Directory.CreateDirectory(path);
}
entry.ExtractToFile(Path.Combine(tempPath, entry.FullName));
}
}
}
else
{
// Something else!
using (var stream = File.Open(zipDir, FileMode.Open))
using (var files = TarReader.Open(stream))
{
Directory.CreateDirectory(tempPath);
files.WriteAllToDirectory(tempPath, new ExtractionOptions { Overwrite = true });
}
}
}
public static async Task DownloadAsync(string requestUri, string filename, PerformContext ctx)
{
using (var client = new WebClient())

@ -17,6 +17,7 @@
<PackageReference Include="Hangfire.RecurringJobExtensions" Version="1.1.6" />
<PackageReference Include="Hangfire.SQLite" Version="1.4.2" />
<PackageReference Include="Serilog" Version="2.6.0-dev-00892" />
<PackageReference Include="SharpCompress" Version="0.18.2" />
<PackageReference Include="System.Diagnostics.Process" Version="4.3.0" />
</ItemGroup>

@ -7,8 +7,8 @@ using Ombi.Api.Service;
using Ombi.Attributes;
using Ombi.Helpers;
using Ombi.Schedule.Jobs.Emby;
using Ombi.Schedule.Jobs.Ombi;
using Ombi.Schedule.Jobs.Plex;
using Ombi.Schedule.Ombi;
namespace Ombi.Controllers
{

Loading…
Cancel
Save