From 38bd9ae1df0848446a3f7be8dcac1a6cae61928e Mon Sep 17 00:00:00 2001 From: Lanta Date: Tue, 14 Nov 2023 10:45:07 +0100 Subject: [PATCH] s --- discord/report_new_matches.ps1 | 2 +- discord/report_to_discord.ps1 | 2 +- includes/ps1/lockfile.ps1 | 9 +++++++++ update/get_matches.ps1 | 2 +- update/matchparser.ps1 | 2 +- update/update_clan.ps1 | 6 ++++-- update/update_clan_members.ps1 | 2 +- 7 files changed, 18 insertions(+), 7 deletions(-) diff --git a/discord/report_new_matches.ps1 b/discord/report_new_matches.ps1 index 529a2e4..e2a5276 100644 --- a/discord/report_new_matches.ps1 +++ b/discord/report_new_matches.ps1 @@ -7,7 +7,7 @@ else { $scriptroot = $PSScriptRoot } . $scriptroot\..\includes\ps1\lockfile.ps1 -new-lock +new-lock -by "report_new_matches" $fileContent = Get-Content -Path "$scriptroot/../config/config.php" -Raw diff --git a/discord/report_to_discord.ps1 b/discord/report_to_discord.ps1 index 5369ffd..c738e0c 100644 --- a/discord/report_to_discord.ps1 +++ b/discord/report_to_discord.ps1 @@ -7,7 +7,7 @@ else { $scriptroot = $PSScriptRoot } . $scriptroot\..\includes\ps1\lockfile.ps1 -new-lock +new-lock -by "report_to_discord" function IsValidEntry($entry) { return ($entry.KD_H -ne 'NaN' -and $entry.KD_ALL -ne 'NaN') -and ($entry.KD_H -ne 'Infinity' -and $entry.KD_ALL -ne 'Infinity') diff --git a/includes/ps1/lockfile.ps1 b/includes/ps1/lockfile.ps1 index ef5ecff..54f83cb 100644 --- a/includes/ps1/lockfile.ps1 +++ b/includes/ps1/lockfile.ps1 @@ -1,4 +1,10 @@ function new-lock { + [CmdletBinding()] + param ( + [Parameter()] + [string] + $by + ) Write-Output 'Setting lock' $lock = $true $timeout = 10 @@ -23,6 +29,9 @@ function new-lock { $i++ } New-Item -ItemType File -Path $lockFile | Out-Null + if ($by) { + $by | Out-File -FilePath $lockFile -Append + } } function remove-lock { diff --git a/update/get_matches.ps1 b/update/get_matches.ps1 index f089f5f..832c312 100644 --- a/update/get_matches.ps1 +++ b/update/get_matches.ps1 @@ -6,7 +6,7 @@ else { } . $scriptroot\..\includes\ps1\lockfile.ps1 -new-lock +new-lock -by "get_matches" # Read the content of the file as a single string $fileContent = Get-Content -Path "$scriptroot/../config/config.php" -Raw diff --git a/update/matchparser.ps1 b/update/matchparser.ps1 index 4345b9a..2a04d5c 100644 --- a/update/matchparser.ps1 +++ b/update/matchparser.ps1 @@ -10,7 +10,7 @@ else { } . $scriptroot\..\includes\ps1\lockfile.ps1 -new-lock +new-lock -by "matchparser" ##SETTINGS $monthsback = -1 # how many months back to look for matches ##END OF SETTINGS diff --git a/update/update_clan.ps1 b/update/update_clan.ps1 index 5c9b66a..7573ee0 100644 --- a/update/update_clan.ps1 +++ b/update/update_clan.ps1 @@ -1,11 +1,13 @@ -. .\..\includes\ps1\lockfile.ps1 + + -new-lock if($PSScriptRoot.length -eq 0){ $scriptroot = Get-Location }else{ $scriptroot = $PSScriptRoot } +. $scriptroot\..\includes\ps1\lockfile.ps1 +new-lock -by "update_clan" # Read the content of the file as a single string $fileContent = Get-Content -Path "$scriptroot/../config/config.php" -Raw diff --git a/update/update_clan_members.ps1 b/update/update_clan_members.ps1 index fea573e..1b32f5a 100644 --- a/update/update_clan_members.ps1 +++ b/update/update_clan_members.ps1 @@ -10,7 +10,7 @@ else { } . $scriptroot\..\includes\ps1\lockfile.ps1 -new-lock +new-lock -by "update_clan_members" # Read the content of the file as a single string $fileContent = Get-Content -Path "$scriptroot/../config/config.php" -Raw