Skip to content

Commit

Permalink
repair the read-only file bug #762
Browse files Browse the repository at this point in the history
  • Loading branch information
Scighost committed May 25, 2024
1 parent 75e2d27 commit 8c32e6d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public override async Task StartAsync(bool skipVerify = false)
CanCancel = false;
cancellationTokenSource?.Cancel();
cancellationTokenSource = new CancellationTokenSource();
SetAllFileWriteable();

if (_inState != InstallGameState.Download || skipVerify)
{
Expand Down
15 changes: 15 additions & 0 deletions src/Starward/Services/InstallGame/InstallGameService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ public virtual async Task StartAsync(bool skipVerify = false)
CanCancel = false;
cancellationTokenSource?.Cancel();
cancellationTokenSource = new CancellationTokenSource();
SetAllFileWriteable();

if (_inState != InstallGameState.Download || skipVerify)
{
Expand Down Expand Up @@ -282,6 +283,20 @@ public virtual async Task StartAsync(bool skipVerify = false)
}


/// <summary>
/// 使所有文件可写
/// </summary>
protected void SetAllFileWriteable()
{
var files = Directory.GetFiles(InstallPath, "*", SearchOption.AllDirectories);
foreach (var file in files)
{
File.SetAttributes(file, FileAttributes.Normal);
}
}



/// <summary>
/// 准备下载
/// </summary>
Expand Down

0 comments on commit 8c32e6d

Please sign in to comment.