mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Remove the disk store (#7170)
The disk store has not been written to since MetaMask v4.3.0, as it was removed in #3083. It was kept around so that anything written to disk prior to v4.3.0 could still be restored. It has been a year and a half since that release, so I think it's time to remove the disk store altogether. The consequences of losing locally stored data are small anyway - it's an inconvenience at worst.
This commit is contained in:
parent
3696e4c648
commit
b5da8a237e
@ -14,7 +14,6 @@ const pump = require('pump')
|
|||||||
const debounce = require('debounce-stream')
|
const debounce = require('debounce-stream')
|
||||||
const log = require('loglevel')
|
const log = require('loglevel')
|
||||||
const extension = require('extensionizer')
|
const extension = require('extensionizer')
|
||||||
const LocalStorageStore = require('obs-store/lib/localStorage')
|
|
||||||
const LocalStore = require('./lib/local-store')
|
const LocalStore = require('./lib/local-store')
|
||||||
const storeTransform = require('obs-store/lib/transform')
|
const storeTransform = require('obs-store/lib/transform')
|
||||||
const asStream = require('obs-store/lib/asStream')
|
const asStream = require('obs-store/lib/asStream')
|
||||||
@ -43,7 +42,6 @@ const {
|
|||||||
// METAMASK_TEST_CONFIG is used in e2e tests to set the default network to localhost
|
// METAMASK_TEST_CONFIG is used in e2e tests to set the default network to localhost
|
||||||
const firstTimeState = Object.assign({}, rawFirstTimeState, global.METAMASK_TEST_CONFIG)
|
const firstTimeState = Object.assign({}, rawFirstTimeState, global.METAMASK_TEST_CONFIG)
|
||||||
|
|
||||||
const STORAGE_KEY = 'metamask-config'
|
|
||||||
const METAMASK_DEBUG = process.env.METAMASK_DEBUG
|
const METAMASK_DEBUG = process.env.METAMASK_DEBUG
|
||||||
|
|
||||||
log.setDefaultLevel(process.env.METAMASK_DEBUG ? 'debug' : 'warn')
|
log.setDefaultLevel(process.env.METAMASK_DEBUG ? 'debug' : 'warn')
|
||||||
@ -67,7 +65,6 @@ let notificationIsOpen = false
|
|||||||
const openMetamaskTabsIDs = {}
|
const openMetamaskTabsIDs = {}
|
||||||
|
|
||||||
// state persistence
|
// state persistence
|
||||||
const diskStore = new LocalStorageStore({ storageKey: STORAGE_KEY })
|
|
||||||
const localStore = new LocalStore()
|
const localStore = new LocalStore()
|
||||||
let versionedData
|
let versionedData
|
||||||
|
|
||||||
@ -180,7 +177,6 @@ async function loadStateFromPersistence () {
|
|||||||
// read from disk
|
// read from disk
|
||||||
// first from preferred, async API:
|
// first from preferred, async API:
|
||||||
versionedData = (await localStore.get()) ||
|
versionedData = (await localStore.get()) ||
|
||||||
diskStore.getState() ||
|
|
||||||
migrator.generateInitialState(firstTimeState)
|
migrator.generateInitialState(firstTimeState)
|
||||||
|
|
||||||
// check if somehow state is empty
|
// check if somehow state is empty
|
||||||
@ -188,21 +184,9 @@ async function loadStateFromPersistence () {
|
|||||||
// for a small number of users
|
// for a small number of users
|
||||||
// https://github.com/metamask/metamask-extension/issues/3919
|
// https://github.com/metamask/metamask-extension/issues/3919
|
||||||
if (versionedData && !versionedData.data) {
|
if (versionedData && !versionedData.data) {
|
||||||
// try to recover from diskStore incase only localStore is bad
|
// unable to recover, clear state
|
||||||
const diskStoreState = diskStore.getState()
|
versionedData = migrator.generateInitialState(firstTimeState)
|
||||||
if (diskStoreState && diskStoreState.data) {
|
sentry.captureMessage('MetaMask - Empty vault found - unable to recover')
|
||||||
// we were able to recover (though it might be old)
|
|
||||||
versionedData = diskStoreState
|
|
||||||
const vaultStructure = getObjStructure(versionedData)
|
|
||||||
sentry.captureMessage('MetaMask - Empty vault found - recovered from diskStore', {
|
|
||||||
// "extra" key is required by Sentry
|
|
||||||
extra: { vaultStructure },
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
// unable to recover, clear state
|
|
||||||
versionedData = migrator.generateInitialState(firstTimeState)
|
|
||||||
sentry.captureMessage('MetaMask - Empty vault found - unable to recover')
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// report migration errors to sentry
|
// report migration errors to sentry
|
||||||
|
Loading…
Reference in New Issue
Block a user