mirror of
https://github.com/SpotX-Official/SpotX.git
synced 2026-04-23 19:40:19 +10:00
Update cache_spotify.ps1
Properly join the path to prevent falsely flagging the path as nonexistent.
This commit is contained in:
8
scripts/cache/cache_spotify.ps1
vendored
8
scripts/cache/cache_spotify.ps1
vendored
@@ -12,13 +12,13 @@ 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
|
# Clear the \Data folder if it finds an outdated cache
|
||||||
|
|
||||||
try {
|
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
|
"$(Get-Date -Format "dd/MM/yyyy HH:mm:ss") Folder Local\Spotify\Data not found" | Out-File log.txt -append
|
||||||
exit
|
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) {
|
if ($check.Length -ge 1) {
|
||||||
|
|
||||||
$count = $check
|
$count = $check
|
||||||
@@ -31,7 +31,7 @@ try {
|
|||||||
$mb = "{0:N2} Mb" -f (($check | Measure-Object Length -s).sum / 1Mb)
|
$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-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) {
|
if ($check.Length -lt 1) {
|
||||||
"$(Get-Date -Format "dd/MM/yyyy HH:mm:ss") Stale cache not found" | Out-File log.txt -append
|
"$(Get-Date -Format "dd/MM/yyyy HH:mm:ss") Stale cache not found" | Out-File log.txt -append
|
||||||
|
|||||||
Reference in New Issue
Block a user