mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-07-03 02:52:30 +00:00
fix: add back existence check
This commit is contained in:
parent
1a33adc001
commit
0b940faf22
26
src/Cache.js
26
src/Cache.js
@ -39,17 +39,23 @@ class Cache {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
|
||||||
// console.log("load cache:", cacheFile)
|
// console.log("load cache:", cacheFile)
|
||||||
filePath = cacheFile
|
store.exists(cacheFile, (err, exists) => {
|
||||||
pull(
|
if (err || !exists) {
|
||||||
store.read(cacheFile),
|
return resolve()
|
||||||
pull.collect((err, res) => {
|
}
|
||||||
if (err) {
|
|
||||||
return reject(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
resolve(JSON.parse(res[0].toString() || '{}'))
|
filePath = cacheFile
|
||||||
})
|
pull(
|
||||||
)
|
store.read(cacheFile),
|
||||||
|
pull.collect((err, res) => {
|
||||||
|
if (err) {
|
||||||
|
return reject(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
resolve(JSON.parse(res[0].toString() || '{}'))
|
||||||
|
})
|
||||||
|
)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user