Merge pull request #869 from cvium/only_zips

Remove DLL support and require all packages/plugins to be zip archives
pull/886/head
Joshua M. Boniface 6 years ago committed by GitHub
commit 0ff38b6012
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -529,20 +529,18 @@ namespace Emby.Server.Implementations.Updates
private async Task PerformPackageInstallation(IProgress<double> progress, string target, PackageVersionInfo package, CancellationToken cancellationToken) private async Task PerformPackageInstallation(IProgress<double> progress, string target, PackageVersionInfo package, CancellationToken cancellationToken)
{ {
// Target based on if it is an archive or single assembly
var extension = Path.GetExtension(package.targetFilename); var extension = Path.GetExtension(package.targetFilename);
var isArchive = string.Equals(extension, ".zip", StringComparison.OrdinalIgnoreCase); var isArchive = string.Equals(extension, ".zip", StringComparison.OrdinalIgnoreCase);
if (target == null) if (!isArchive)
{
if (isArchive)
{ {
target = Path.Combine(_appPaths.PluginsPath, Path.GetFileNameWithoutExtension(package.targetFilename)); _logger.LogError("Only zip packages are supported. {Filename} is not a zip archive.", package.targetFilename);
return;
} }
else
if (target == null)
{ {
target = Path.Combine(_appPaths.PluginsPath, package.targetFilename); target = Path.Combine(_appPaths.PluginsPath, Path.GetFileNameWithoutExtension(package.targetFilename));
}
} }
// Download to temporary file so that, if interrupted, it won't destroy the existing installation // Download to temporary file so that, if interrupted, it won't destroy the existing installation
@ -560,23 +558,15 @@ namespace Emby.Server.Implementations.Updates
// Success - move it to the real target // Success - move it to the real target
try try
{
if (isArchive)
{ {
using (var stream = File.OpenRead(tempFile)) using (var stream = File.OpenRead(tempFile))
{ {
_zipClient.ExtractAllFromZip(stream, target, true); _zipClient.ExtractAllFromZip(stream, target, true);
} }
} }
else
{
Directory.CreateDirectory(Path.GetDirectoryName(target));
File.Copy(tempFile, target, true);
}
}
catch (IOException ex) catch (IOException ex)
{ {
_logger.LogError(ex, "Error attempting to move file from {TempFile} to {TargetFile}", tempFile, target); _logger.LogError(ex, "Error attempting to extract {TempFile} to {TargetFile}", tempFile, target);
throw; throw;
} }

Loading…
Cancel
Save