Add a setting to clear cache
This commit is contained in:
1 parent
0bbb876a84
commit
55c811adb7
14 files changed
+192
No files matched your search
@@ -0,0 +1,10 @@
|
||||
import "pkg:/source/AsyncTask/AsyncTask.bs"
|
||||
import "pkg:/source/AsyncTask/Tasks.bs"
|
||||
|
||||
namespace CacheUtils
|
||||
|
||||
function Clear()
|
||||
AsyncTask.Start(Tasks.ClearCacheTask, invalid)
|
||||
end function
|
||||
|
||||
end namespace
|
||||
@@ -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
|
||||
@@ -283,6 +283,9 @@ namespace Locale
|
||||
UseDevVideoPlayerDescription = "Enable the dev video player. This is an unfinished video player for testing purposes."
|
||||
PlayletLibraryVersion = "Playlet Library version"
|
||||
PlayletLibraryVersionDescription = "The version of Playlet Lib to use. These correspond to tagged releases on Github. Releases that do not have a playlet-lib.zip file are disabled."
|
||||
ClearCache = "Clear cache"
|
||||
ClearCacheDescription = "Clear cache from cachefs: and tmp:"
|
||||
CacheCleared = "Cache cleared."
|
||||
end enum
|
||||
|
||||
@locale
|
||||
|
||||
Reference in new issue
Block a user