use temp dir for cache

Signed-off-by: Benny Samir Hierl <bennysamir@posteo.de>
This commit is contained in:
Benny Samir Hierl 2020-10-24 15:14:21 +02:00
parent 66346de898
commit c1bbe6886d
No known key found for this signature in database
GPG key ID: 69DE3C3C097DB7F7

View file

@ -19,7 +19,10 @@ async function loadScript(url) {
let content = await req.loadString() let content = await req.loadString()
let filename = url.split('/').pop() let filename = url.split('/').pop()
return {content, filename} return {
content,
filename
}
} }
async function downloadWidget(widget) { async function downloadWidget(widget) {
@ -29,7 +32,10 @@ async function downloadWidget(widget) {
downloadAlert.addCancelAction('No') downloadAlert.addCancelAction('No')
if (await downloadAlert.presentAlert() === 0) { if (await downloadAlert.presentAlert() === 0) {
let {content, filename} = await loadScript(widget.scriptURL) let {
content,
filename
} = await loadScript(widget.scriptURL)
const scriptPath = fmCloud.joinPath(fmCloud.documentsDirectory(), filename) const scriptPath = fmCloud.joinPath(fmCloud.documentsDirectory(), filename)
const scriptExists = fmCloud.fileExists(scriptPath) const scriptExists = fmCloud.fileExists(scriptPath)
@ -90,7 +96,7 @@ function populateWidgetTable(table, widgets){
module.exports.present = async () => { module.exports.present = async () => {
// Set up cache . // Set up cache .
const cachePath = fmLocal.joinPath(fmLocal.documentsDirectory(), "widget-catalog") const cachePath = fmLocal.joinPath(fmLocal.temporaryDirectory(), "cache-widget-catalog")
const cacheExists = fmLocal.fileExists(cachePath) const cacheExists = fmLocal.fileExists(cachePath)
const cacheDate = cacheExists ? fmLocal.modificationDate(cachePath) : 0 const cacheDate = cacheExists ? fmLocal.modificationDate(cachePath) : 0