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