-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve cache file writer with more robust handling
- Loading branch information
1 parent
fa66de0
commit 50a82d1
Showing
5 changed files
with
69 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
function Copy-IcingaCacheTempFile() | ||
{ | ||
param ( | ||
[string]$CacheFile = '', | ||
[string]$CacheTmpFile = '' | ||
); | ||
|
||
# Copy the new file over the old one | ||
Copy-ItemSecure -Path $CacheTmpFile -Destination $CacheFile -Force | Out-Null; | ||
# Remove the old file | ||
Remove-ItemSecure -Path $CacheTmpFile -Retries 5 -Force | Out-Null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
function Test-IcingaCacheDataTempFile() | ||
{ | ||
param ( | ||
[string]$Space, | ||
[string]$CacheStore | ||
); | ||
|
||
# Once the file is written successully, validate it is fine | ||
$tmpContent = Get-IcingaCacheData -Space $Space -CacheStore $CacheStore -TempFile; | ||
|
||
if ($null -eq $tmpContent) { | ||
# File is corrupt or empty | ||
return $FALSE; | ||
} | ||
|
||
return $TRUE; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters