check whether the file is in use, dependent runtime-dlls will distribute
This commit is contained in:
parent
e615263706
commit
4bdf20822f
|
@ -1,13 +1,13 @@
|
||||||
using System.Reflection;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using Microsoft.Extensions.Hosting;
|
using System.Reflection;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using Oqtane.Shared;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using System;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using Microsoft.Extensions.Caching.Memory;
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using Oqtane.Shared;
|
||||||
|
|
||||||
namespace Oqtane.Infrastructure
|
namespace Oqtane.Infrastructure
|
||||||
{
|
{
|
||||||
|
@ -101,6 +101,11 @@ namespace Oqtane.Infrastructure
|
||||||
filename = Path.Combine(webRootPath, Utilities.PathCombine(entry.FullName.Replace($"wwwroot{Path.DirectorySeparatorChar}", "").Split(Path.DirectorySeparatorChar)));
|
filename = Path.Combine(webRootPath, Utilities.PathCombine(entry.FullName.Replace($"wwwroot{Path.DirectorySeparatorChar}", "").Split(Path.DirectorySeparatorChar)));
|
||||||
ExtractFile(entry, filename);
|
ExtractFile(entry, filename);
|
||||||
break;
|
break;
|
||||||
|
case "runtimes":
|
||||||
|
var destSubFolder = Path.GetDirectoryName(entry.FullName);
|
||||||
|
filename = Path.Combine(binFolder, destSubFolder, filename);
|
||||||
|
ExtractFile(entry, filename);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,9 +126,24 @@ namespace Oqtane.Infrastructure
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(filename));
|
Directory.CreateDirectory(Path.GetDirectoryName(filename));
|
||||||
}
|
}
|
||||||
entry.ExtractToFile(filename, true);
|
if (FileInUse(filename) == false)
|
||||||
|
entry.ExtractToFile(filename, true);
|
||||||
|
}
|
||||||
|
private static bool FileInUse(string path)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate))
|
||||||
|
{
|
||||||
|
var flag = fs.CanWrite;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch (IOException ex)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpgradeFramework()
|
public void UpgradeFramework()
|
||||||
{
|
{
|
||||||
string folder = Path.Combine(_environment.WebRootPath, "Framework");
|
string folder = Path.Combine(_environment.WebRootPath, "Framework");
|
||||||
|
@ -131,7 +151,7 @@ namespace Oqtane.Infrastructure
|
||||||
{
|
{
|
||||||
// get package with highest version and clean up any others
|
// get package with highest version and clean up any others
|
||||||
string packagename = "";
|
string packagename = "";
|
||||||
foreach(string package in Directory.GetFiles(folder, "Oqtane.Framework.*.nupkg"))
|
foreach (string package in Directory.GetFiles(folder, "Oqtane.Framework.*.nupkg"))
|
||||||
{
|
{
|
||||||
if (packagename != "")
|
if (packagename != "")
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user