Skip to content

Commit

Permalink
Tidy up
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkeye116477 committed Nov 16, 2024
1 parent 93f146a commit 2bea64a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
1 change: 1 addition & 0 deletions src/Models/UpdateInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ public class UpdateInfo
public string Title { get; set; }
public double Download_size { get; set; } = 0;
public bool Success { get; set; } = true;
public string Install_path { get; set; } = "";
}
}
14 changes: 0 additions & 14 deletions src/NileDownloadManagerView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,20 +234,6 @@ public async Task Install(DownloadManagerData.Download taskData)
}
installCommand.Add(gameID);

if (downloadProperties.installPath != "" && downloadProperties.downloadAction == DownloadAction.Install)
{
var folderName = gameTitle.RemoveTrademarks();
string[] inappropriateDirChars = { ":", "/", "*", "?", "<", ">", "\\", "|", "™", "\"", "®" };
foreach (var inappropriateDirChar in inappropriateDirChars)
{
folderName = folderName.Replace(inappropriateDirChar, "");
}
taskData.fullInstallPath = Path.Combine(downloadProperties.installPath, folderName);
}
else if (downloadProperties.installPath != "")
{
taskData.fullInstallPath = downloadProperties.installPath;
}
if (!taskData.fullInstallPath.IsNullOrEmpty())
{
installCommand.AddRange(new[] { "--path", taskData.fullInstallPath });
Expand Down
11 changes: 10 additions & 1 deletion src/NileGameController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,10 @@ public async Task<Dictionary<string, UpdateInfo>> CheckAllGamesUpdates(bool sile
{
updateInfo.Download_size = gameInfo.download_size;
updateInfo.Title = gameInfo.title;
if (appList.FirstOrDefault(i => i.id == gameToUpdate) != null)
{
updateInfo.Install_path = appList.FirstOrDefault(i => i.id == gameToUpdate).path;
}
}
gamesToUpdate.Add(gameToUpdate, updateInfo);
}
Expand Down Expand Up @@ -589,12 +593,17 @@ public async Task UpdateGame(Dictionary<string, UpdateInfo> gamesToUpdate, strin
maxWorkers = settings.MaxWorkers,
};
}
if (!gameToUpdate.Value.Install_path.IsNullOrEmpty())
{
downloadProperties.installPath = gameToUpdate.Value.Install_path;
}
var updateTask = new DownloadManagerData.Download
{
gameID = gameToUpdate.Key,
name = gameToUpdate.Value.Title,
downloadSizeNumber = gameToUpdate.Value.Download_size,
downloadProperties = downloadProperties
downloadProperties = downloadProperties,
fullInstallPath = downloadProperties.installPath
};
updateTasks.Add(updateTask);
}
Expand Down
13 changes: 12 additions & 1 deletion src/NileGameInstallerView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,20 @@ public async Task StartTask(DownloadAction downloadAction)
var wantedItem = downloadManager.downloadManagerData.downloads.FirstOrDefault(item => item.gameID == gameId);
if (wantedItem == null)
{
if (!installData.downloadProperties.installPath.IsNullOrEmpty())
if (installData.downloadProperties.downloadAction == DownloadAction.Install)
{
var folderName = installData.name;
string[] inappropriateDirChars = { ":", "/", "*", "?", "<", ">", "\\", "|", "™", "\"", "®" };
foreach (var inappropriateDirChar in inappropriateDirChars)
{
folderName = folderName.Replace(inappropriateDirChar, "");
}
installData.fullInstallPath = Path.Combine(installData.downloadProperties.installPath, folderName);
}
else if (!installData.downloadProperties.installPath.IsNullOrEmpty())
{
installPath = installData.downloadProperties.installPath;
installData.fullInstallPath = installPath;
}
if (!CommonHelpers.IsDirectoryWritable(installPath, LOC.NilePermissionError))
{
Expand Down

0 comments on commit 2bea64a

Please sign in to comment.