Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ process.on('unhandledRejection', fatal)
export default {
events: new EventEmitter(),
debug: debug,
appData: ipfsAppData,
settingsStore: settingsStore,
logo: {
ice: logo('ice'),
Expand Down
31 changes: 31 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,34 @@ function onRequestState (node, event) {
send('node-status', state)
}

// Moves files from appData/file-history.json to MFS so
// v0.4.0 is backwards compatible with v0.3.0.
function moveFilesOver () {
const path = join(config.appData, 'file-history.json')

if (!fs.existsSync(path)) {
return
}

let files

try {
files = JSON.parse(fs.readFileSync(path))
} catch (e) {
debug(e)
return
}

Promise.all(files.map((file) => IPFS.files.cp([`/ipfs/${file.hash}`, `/${file.name}`])))
.then(() => {
fs.unlinkSync(path)
})
.catch((e) => {
fs.unlinkSync(path)
debug(e)
})
}

function onStartDaemon (node) {
debug('Starting daemon')
updateState('starting')
Expand Down Expand Up @@ -99,6 +127,9 @@ function onStartDaemon (node) {
})
}

// Move files from V0.3.0
moveFilesOver()

menubar.tray.setImage(config.logo.ice)
updateState('running')
})
Expand Down