fix #5005 - adds versioning (ie. fingerprinting) for static assets - core, modules, and themes.
This commit is contained in:
@ -286,7 +286,7 @@ namespace Oqtane.Controllers
|
||||
DateTime lastwritetime = System.IO.File.GetLastWriteTime(filepath);
|
||||
if (hashfilename)
|
||||
{
|
||||
HashedName = GetDeterministicHashCode(filepath).ToString("X8") + "." + lastwritetime.ToString("yyyyMMddHHmmss") + Path.GetExtension(filepath);
|
||||
HashedName = Utilities.GenerateSimpleHash(filepath) + "." + lastwritetime.ToString("yyyyMMddHHmmss") + Path.GetExtension(filepath);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -297,25 +297,5 @@ namespace Oqtane.Controllers
|
||||
public string FilePath { get; private set; }
|
||||
public string HashedName { get; private set; }
|
||||
}
|
||||
|
||||
private static int GetDeterministicHashCode(string value)
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
int hash1 = (5381 << 16) + 5381;
|
||||
int hash2 = hash1;
|
||||
|
||||
for (int i = 0; i < value.Length; i += 2)
|
||||
{
|
||||
hash1 = ((hash1 << 5) + hash1) ^ value[i];
|
||||
if (i == value.Length - 1)
|
||||
break;
|
||||
hash2 = ((hash2 << 5) + hash2) ^ value[i + 1];
|
||||
}
|
||||
|
||||
return hash1 + (hash2 * 1566083941);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ namespace Oqtane.Controllers
|
||||
if (user != null)
|
||||
{
|
||||
email = user.Email;
|
||||
_configManager.AddOrUpdateSetting("PackageRegistryEmail", email, false);
|
||||
_configManager.AddOrUpdateSetting("PackageRegistryEmail", email, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user