andro23
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2018
04:58 AM
Cachefs Unpredictable Behaviour
I am writing an app that downloads some images during its runtime putting them in the cache (cachefs:/MyAppImages).
A 32GB microSD is attached to my Roku Ultra 4640X having the latest OS version 8.0.1 build 4042-29.
After restarting the app, sometimes it is able to find cachef:/MyAppImages with the images downloaded inside; other times it doesn't find the directory and it keeps on downloading the images again and again. When I go check the memory card usage in Settings -> System -> About, I find it having the same usage that it had right after Roku formatted it (1.7/31.4 GB). I was expecting that it won't remove my cached files unless the memory card is full and the device needs more space on the memory card for other usages. Any idea why it is doing that?
A 32GB microSD is attached to my Roku Ultra 4640X having the latest OS version 8.0.1 build 4042-29.
After restarting the app, sometimes it is able to find cachef:/MyAppImages with the images downloaded inside; other times it doesn't find the directory and it keeps on downloading the images again and again. When I go check the memory card usage in Settings -> System -> About, I find it having the same usage that it had right after Roku formatted it (1.7/31.4 GB). I was expecting that it won't remove my cached files unless the memory card is full and the device needs more space on the memory card for other usages. Any idea why it is doing that?
3 REPLIES 3
andro23
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2018
01:54 AM
Re: Cachefs Unpredictable Behaviour
I changed my approach and created files on root cachefs:/ and it worked as expected and documented this time.
Cessilva
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2020
10:56 AM
Re: Cachefs Unpredictable Behaviour
Hi, could you put your code please? It would be very helpful
andro23
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2020
07:36 PM
Re: Cachefs Unpredictable Behaviour
Hi Cessilva, sure! I use this function to download files to cachefs :
function DownloadFile(url as String, fileName as String) as object
returnValue = {}
urlObj = CreateObject("roUrlTransfer")
urlObj.SetRequest("GET")
urlObj.SetUrl(url.EncodeUri())
urlObj.RetainBodyOnError(true)
urlObj.SetCertificatesFile("common:/certs/ca-bundle.crt")
urlObj.InitClientCertificates()
urlObj.AddHeader("X-Roku-Reserved-Dev-Id", "")
urlObj.AddHeader("Content-Type", "text/plain")
urlObj.AddHeader("Accept", "*/*")
port = CreateObject("roMessagePort")
urlObj.SetMessagePort(port)
filePath = "cachefs:/" + fileName
if(urlObj.AsyncGetToFile(filePath))
while(true)
msg = wait(0, port)
if(type(msg) = "roUrlEvent")
code = msg.GetResponseCode()
if(code = 200)
returnValue.success = true
returnValue.filePath = filePath
else
returnValue.success = false
returnValue.code = code
returnValue.errorMessage = "Failed to download file: '" + fileName + "'. Code: " + code.toStr() + ". Reason: " + msg.GetFailureReason()
urlObj.AsyncCancel()
end if
else
returnValue.success = false
returnValue.errorMessage = "Invalid event"
urlObj.AsyncCancel()
end if
exit while
end while
else
returnValue.success = false
returnValue.errorMessage = "Download request could not be issued."
urlObj.AsyncCancel()
end if
return returnValue
end function