Add a setting to clear cache

This commit is contained in:
Brahim Hadriche committed 2024-05-21 17:41:30 -04:00
1 parent 0bbb876a84
commit 55c811adb7
14 files changed
+192

No files matched your search

@@ -0,0 +1,33 @@
import "pkg:/source/utils/Logging.bs"
@asynctask
function ClearCacheTask() as object
fs = CreateObject("roFileSystem")
if fs = invalid
LogError("Failed to create roFileSystem object")
return invalid
end if
ClearVolume(fs, "tmp:/")
ClearVolume(fs, "cachefs:/")
return invalid
end function
function ClearVolume(fs as object, volume as string)
items = fs.GetDirectoryListing(volume)
for each item in items
fullpath = volume + item
' Skip logs directory
if fullpath = "cachefs:/logs"
continue for
end if
if not fs.Delete(fullpath)
LogError("Failed to delete:", fullpath)
end if
end for
LogInfo("Cleared:", volume)
end function