Skip to content

Commit

Permalink
fix:[#366]sequence contains no element
Browse files Browse the repository at this point in the history
  • Loading branch information
RayWangQvQ committed Dec 14, 2022
1 parent acb0e60 commit 74a568d
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/Ray.BiliBiliTool.Application/LoginTaskAppService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ protected void AddOrUpdateCkToQingLong(BiliCookie ckInfo)
return;
}

var list = re.Data.Where(x=>x.name.StartsWith("Ray_BiliBiliCookies__"));
var list = re.Data.Where(x => x.name.StartsWith("Ray_BiliBiliCookies__")).ToList();
QingLongEnv oldEnv = list.FirstOrDefault(x => x.value.Contains(ckInfo.UserId));

if (oldEnv != null)
Expand All @@ -245,13 +245,17 @@ protected void AddOrUpdateCkToQingLong(BiliCookie ckInfo)
}

_logger.LogInformation("用户不存在,新增cookie");
var lastNum = list.Select(x =>
var maxNum = -1;
if (list.Any())
{
var num = x.name.Replace("Ray_BiliBiliCookies__","");
var parseSuc= int.TryParse(num, out int envNum);
return parseSuc ? envNum : 0;
}).MaxBy(x=>x);
var name = $"Ray_BiliBiliCookies__{lastNum + 1}";
maxNum = list.Select(x =>
{
var num = x.name.Replace("Ray_BiliBiliCookies__", "");
var parseSuc = int.TryParse(num, out int envNum);
return parseSuc ? envNum : 0;
}).Max();
}
var name = $"Ray_BiliBiliCookies__{maxNum + 1}";
_logger.LogInformation("Key:{key}", name);

var add = new AddQingLongEnv()
Expand Down Expand Up @@ -378,7 +382,7 @@ private bool GetToken(out string token)

var qlDir = _configuration["QL_DIR"] ?? "/ql";

string authFile= qlDir;
string authFile = qlDir;
if (_hostingEnvironment.ContentRootPath.Contains($"{qlDir}/data/"))
{
authFile = Path.Combine(authFile, "data");
Expand Down

0 comments on commit 74a568d

Please sign in to comment.