Skip to content

Commit

Permalink
chore: fix CultureNotFoundException: Only the invariant culture is su…
Browse files Browse the repository at this point in the history
…pported in globalization-invariant mode

Signed-off-by: 陳鈞 <[email protected]>
  • Loading branch information
jim60105 committed Mar 7, 2024
1 parent fae47d6 commit e6f7313
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Helper/NameHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static string GetInstanceName(string id)
.Split(".", StringSplitOptions.RemoveEmptyEntries).First()
.Replace("_", "")
.Replace(":", "")
.ToLower(new CultureInfo("en-US"));
.ToLower(CultureInfo.InvariantCulture);

public static string GetFileName(Video video, string Platform)
=> Platform switch
Expand Down
3 changes: 2 additions & 1 deletion ScopedServices/PlatformService/YoutubeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#elif COUCHDB
using LivestreamRecorder.DB.CouchDB;
#endif
using System.Globalization;
using LivestreamRecorder.DB.Enums;
using LivestreamRecorder.DB.Interfaces;
using LivestreamRecorderService.Interfaces;
Expand Down Expand Up @@ -306,7 +307,7 @@ public override async Task UpdateVideoDataAsync(Video video, CancellationToken c
video.Timestamps.ActualStartTime ??=
videoData.ReleaseTimestamp.HasValue
? DateTimeOffset.FromUnixTimeSeconds(videoData.ReleaseTimestamp.Value).UtcDateTime
: DateTime.ParseExact(videoData.UploadDate, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture);
: DateTime.ParseExact(videoData.UploadDate, "yyyyMMdd", CultureInfo.InvariantCulture);
video.Thumbnail = await DownloadThumbnailAsync(videoData.Thumbnail, video.id, cancellation);
break;
default:
Expand Down
2 changes: 1 addition & 1 deletion SingletonServices/ACI/ACIServiceBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ protected async Task<ArmOperation<ArmDeploymentResource>> CreateResourceAsync(
}

public string GetInstanceName(string videoId)
=> (Name + NameHelper.GetInstanceName(videoId)).ToLower(new CultureInfo("en-US"));
=> (Name + NameHelper.GetInstanceName(videoId)).ToLower(CultureInfo.InvariantCulture);

private async Task StartOldJobAsync(GenericResource job,
Video video,
Expand Down
2 changes: 1 addition & 1 deletion SingletonServices/Kubernetes/KubernetesServiceBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ private V1Volume GetSharedVolumeDefinition()
};

public string GetInstanceName(string videoId)
=> (Name + NameHelper.GetInstanceName(videoId)).ToLower(new CultureInfo("en-US"));
=> (Name + NameHelper.GetInstanceName(videoId)).ToLower(CultureInfo.InvariantCulture);

// Must be override
protected abstract Task<V1Job> CreateNewJobAsync(string id,
Expand Down

0 comments on commit e6f7313

Please sign in to comment.