1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 17:56:25 +00:00

Fix the assginment of targetStorage

This commit is contained in:
asmsuechan
2017-02-21 23:41:52 +09:00
parent b2187b72ab
commit 928df018dc

View File

@@ -4,16 +4,18 @@ const _ = require('lodash')
const sander = require('sander')
function copyImage (filePath, storageKey) {
let targetStorage
try {
const cachedStorageList = JSON.parse(localStorage.getItem('storages'))
if (!_.isArray(cachedStorageList)) throw new Error('Target storage doesn\'t exist.')
const targetStorage = (() => {
try {
const cachedStorageList = JSON.parse(localStorage.getItem('storages'))
if (!_.isArray(cachedStorageList)) throw new Error('Target storage doesn\'t exist.')
targetStorage = _.find(cachedStorageList, {key: storageKey})
if (targetStorage == null) throw new Error('Target storage doesn\'t exist.')
} catch (e) {
return Promise.reject(e)
}
const storage = _.find(cachedStorageList, {key: storageKey})
if (storage == null) throw new Error('Target storage doesn\'t exist.')
return storage
} catch (e) {
return Promise.reject(e)
}
})()
return new Promise((resolve, reject) => {
try {