Simplify files etag calculation
This commit is contained in:
@ -133,19 +133,10 @@ namespace Oqtane.Pages
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string etag;
|
string etag = Convert.ToString(file.ModifiedOn.Ticks ^ file.Size, 16);
|
||||||
string downloadName = file.Name;
|
string downloadName = file.Name;
|
||||||
string filepath = _files.GetFilePath(file);
|
string filepath = _files.GetFilePath(file);
|
||||||
|
|
||||||
if (Request.QueryString.HasValue)
|
|
||||||
{
|
|
||||||
etag = Utilities.GenerateSimpleHash16($"{file.ModifiedOn.Ticks}:{file.Size}:{Request.QueryString.Value}");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
etag = Convert.ToString(file.ModifiedOn.Ticks ^ file.Size, 16);
|
|
||||||
}
|
|
||||||
|
|
||||||
var header = "";
|
var header = "";
|
||||||
if (HttpContext.Request.Headers.TryGetValue(HeaderNames.IfNoneMatch, out var ifNoneMatch))
|
if (HttpContext.Request.Headers.TryGetValue(HeaderNames.IfNoneMatch, out var ifNoneMatch))
|
||||||
{
|
{
|
||||||
|
@ -620,19 +620,6 @@ namespace Oqtane.Shared
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GenerateSimpleHash16(string text)
|
|
||||||
{
|
|
||||||
unchecked // prevent overflow exception
|
|
||||||
{
|
|
||||||
long hash = 23;
|
|
||||||
foreach (char c in text)
|
|
||||||
{
|
|
||||||
hash = hash * 31 + c;
|
|
||||||
}
|
|
||||||
return hash.ToString("X16");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Obsolete("ContentUrl(Alias alias, int fileId) is deprecated. Use FileUrl(Alias alias, int fileId) instead.", false)]
|
[Obsolete("ContentUrl(Alias alias, int fileId) is deprecated. Use FileUrl(Alias alias, int fileId) instead.", false)]
|
||||||
public static string ContentUrl(Alias alias, int fileId)
|
public static string ContentUrl(Alias alias, int fileId)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user