mirror of
https://github.com/SpotX-Official/SpotX.git
synced 2026-04-14 12:48:22 +10:00
Update cache_spotify.ps1
Properly join the path to prevent falsely flagging the path as nonexistent.
This commit is contained in:
12
scripts/cache/cache_spotify.ps1
vendored
12
scripts/cache/cache_spotify.ps1
vendored
@@ -9,16 +9,16 @@ by the customer more than the specified number of days will be deleted.
|
||||
|
||||
#>
|
||||
|
||||
$day = 7 # Number of days after which the cache is considered stale
|
||||
$day = 7 # Number of days after which the cache is considered stale
|
||||
|
||||
# Clear the \Data folder if it finds an outdated cache
|
||||
|
||||
try {
|
||||
If (!(Test-Path -Path $env:LOCALAPPDATA\Spotify\Data)) {
|
||||
$SpotifyData = Join-Path -Path $env:LOCALAPPDATA -ChildPath "Spotify\Data"
|
||||
If (!(Test-Path -Path $SpotifyData)) {
|
||||
"$(Get-Date -Format "dd/MM/yyyy HH:mm:ss") Folder Local\Spotify\Data not found" | Out-File log.txt -append
|
||||
exit
|
||||
}
|
||||
$check = Get-ChildItem $env:LOCALAPPDATA\Spotify\Data -File -Recurse | Where-Object lastaccesstime -lt (get-date).AddDays(-$day)
|
||||
$check = Get-ChildItem $SpotifyData -File -Recurse | Where-Object lastaccesstime -lt (get-date).AddDays(-$day)
|
||||
if ($check.Length -ge 1) {
|
||||
|
||||
$count = $check
|
||||
@@ -31,7 +31,7 @@ try {
|
||||
$mb = "{0:N2} Mb" -f (($check | Measure-Object Length -s).sum / 1Mb)
|
||||
"$(Get-Date -Format "dd/MM/yyyy HH:mm:ss") Removed $mb obsolete cache" | Out-File log.txt -append
|
||||
}
|
||||
Get-ChildItem $env:LOCALAPPDATA\Spotify\Data -File -Recurse | Where-Object lastaccesstime -lt (get-date).AddDays(-$day) | Remove-Item
|
||||
Get-ChildItem $SpotifyData -File -Recurse | Where-Object lastaccesstime -lt (get-date).AddDays(-$day) | Remove-Item
|
||||
}
|
||||
if ($check.Length -lt 1) {
|
||||
"$(Get-Date -Format "dd/MM/yyyy HH:mm:ss") Stale cache not found" | Out-File log.txt -append
|
||||
@@ -40,4 +40,4 @@ try {
|
||||
catch {
|
||||
"$(Get-Date -Format "dd/MM/yyyy HH:mm:ss") $error[0].Exception" | Out-File log.txt -append
|
||||
}
|
||||
exit
|
||||
exit
|
||||
|
||||
Reference in New Issue
Block a user