mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-07-03 11:02:31 +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) => {
|
||||
|
||||
// console.log("load cache:", cacheFile)
|
||||
filePath = cacheFile
|
||||
pull(
|
||||
store.read(cacheFile),
|
||||
pull.collect((err, res) => {
|
||||
if (err) {
|
||||
return reject(err)
|
||||
}
|
||||
store.exists(cacheFile, (err, exists) => {
|
||||
if (err || !exists) {
|
||||
return resolve()
|
||||
}
|
||||
|
||||
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