Skip to content

Commit

Permalink
Fix: do not try to cache download urls that do not start with http
Browse files Browse the repository at this point in the history
  • Loading branch information
rzander committed Feb 25, 2019
1 parent 67d55d7 commit aabb542
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
22 changes: 12 additions & 10 deletions RZ.Server/RZ.Plugin.Software.Proxy/RZ.Plugin.Software.Proxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,15 +277,18 @@ private void UpdateURLs(ref JArray jSource)

foreach (JObject oFiles in jObj["Files"])
{
if (FileNames.Contains(oFiles["FileName"].Value<string>().ToLower()))
if (oFiles["URL"] != null && oFiles["URL"].ToString().ToLower().StartsWith("http"))
{
//oFiles["URL"] = Base.localURL + "/rest/v2/GetFile/" + sContentID + "/" + oFiles["FileName"].ToString().Replace("\\", "/");
oFiles["URL"] = Base.localURL + "/rest/v2/GetFile/" + sContentID + "/" + oFiles["FileName"].ToString().Replace("\\", "/");

}
else
{
oFiles["URL"] = Base.localURL + "/rest/v2/GetFile/proxy/" + jObj["ShortName"].ToString() + "/" + sContentID + "/" + oFiles["FileName"].ToString().Replace("\\", "/");
if (FileNames.Contains(oFiles["FileName"].Value<string>().ToLower()))
{
//oFiles["URL"] = Base.localURL + "/rest/v2/GetFile/" + sContentID + "/" + oFiles["FileName"].ToString().Replace("\\", "/");
oFiles["URL"] = Base.localURL + "/rest/v2/GetFile/" + sContentID + "/" + oFiles["FileName"].ToString().Replace("\\", "/");

}
else
{
oFiles["URL"] = Base.localURL + "/rest/v2/GetFile/proxy/" + jObj["ShortName"].ToString() + "/" + sContentID + "/" + oFiles["FileName"].ToString().Replace("\\", "/");
}
}
}
}
Expand Down Expand Up @@ -333,6 +336,7 @@ public async Task<Stream> GetFile(string FilePath)

try
{
_cache = new MemoryCache(new MemoryCacheOptions()); //clear cache...
using (HttpClient oClient = new HttpClient())
{
using (var response = await oClient.GetAsync(URL, HttpCompletionOption.ResponseHeadersRead))
Expand Down Expand Up @@ -369,8 +373,6 @@ public async Task<Stream> GetFile(string FilePath)
}
}
}


}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<ItemGroup>
<PackageReference Include="Costura.Fody" Version="3.3.2" />
<PackageReference Include="Fody" Version="4.0.0-beta.1">
<PackageReference Include="Fody" Version="4.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down

0 comments on commit aabb542

Please sign in to comment.