Skip to content

Commit

Permalink
Fix outputcache wrong datetime format cultureinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
thienvc committed Nov 21, 2021
1 parent 4141ee8 commit 1808727
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DNN Platform/Library/Services/ModuleCache/FileProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ private static string GetCacheFolder(int portalId)

if (!string.IsNullOrEmpty(homeDirectoryMapPath))
{
cacheFolder = string.Concat(homeDirectoryMapPath, "Cache\\Pages\\");
cacheFolder = string.Concat(homeDirectoryMapPath, "Cache\\Modules\\");
if (!Directory.Exists(cacheFolder))
{
Directory.CreateDirectory(cacheFolder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
namespace DotNetNuke.Services.OutputCache.Providers
{
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
using System.Web;
Expand Down Expand Up @@ -170,8 +171,15 @@ public override void SetOutput(int tabId, string cacheKey, TimeSpan duration, by
}

using (var oWrite = File.CreateText(attribFile))
{
oWrite.WriteLine(DateTime.UtcNow.Add(duration).ToString());
{
var currentCulture = CultureInfo.CurrentCulture.DateTimeFormat;
var currentCultureX = CultureInfo.DefaultThreadCurrentCulture.DateTimeFormat;

var datetimeUtc = DateTime.UtcNow.Add(duration).ToString(CultureInfo.InvariantCulture);
var datetime1 = DateTime.UtcNow.Add(duration).ToString();
var datetime2 = DateTime.UtcNow.Add(duration).ToString();

oWrite.WriteLine(DateTime.UtcNow.Add(duration).ToString(CultureInfo.InvariantCulture));
oWrite.Close();
}
}
Expand All @@ -192,7 +200,12 @@ public override bool StreamOutput(int tabId, string cacheKey, HttpContext contex
bool foundFile = false;
try
{
string attribFile = GetAttribFileName(tabId, cacheKey);
string attribFile = GetAttribFileName(tabId, cacheKey);
if (!File.Exists(attribFile))
{
return false;
}

string captureFile = GetCachedOutputFileName(tabId, cacheKey);
StreamReader oRead = File.OpenText(attribFile);
DateTime expires = Convert.ToDateTime(oRead.ReadLine());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

namespace DotNetNuke.Services.OutputCache.Providers
{
using System;
using System;
using System.Globalization;
using System.IO;

using DotNetNuke.Common.Utilities;
Expand Down Expand Up @@ -102,7 +103,7 @@ public override byte[] StopFiltering(int itemId, bool deleteData)
File.Move(this.CachedOutputTempFileName, this.CachedOutputFileName);

StreamWriter oWrite = File.CreateText(this.CachedOutputAttribFileName);
oWrite.WriteLine(this._cacheExpiration.ToString());
oWrite.WriteLine(this._cacheExpiration.ToString(CultureInfo.InvariantCulture));
oWrite.Close();
}

Expand Down

0 comments on commit 1808727

Please sign in to comment.