File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ process.on('unhandledRejection', fatal)
58
58
export default {
59
59
events : new EventEmitter ( ) ,
60
60
debug : debug ,
61
+ appData : ipfsAppData ,
61
62
settingsStore : settingsStore ,
62
63
logo : {
63
64
ice : logo ( 'ice' ) ,
Original file line number Diff line number Diff line change @@ -48,6 +48,34 @@ function onRequestState (node, event) {
48
48
send ( 'node-status' , state )
49
49
}
50
50
51
+ // Moves files from appData/file-history.json to MFS so
52
+ // v0.4.0 is backwards compatible with v0.3.0.
53
+ function moveFilesOver ( ) {
54
+ const path = join ( config . appData , 'file-history.json' )
55
+
56
+ if ( ! fs . existsSync ( path ) ) {
57
+ return
58
+ }
59
+
60
+ let files
61
+
62
+ try {
63
+ files = JSON . parse ( fs . readFileSync ( path ) )
64
+ } catch ( e ) {
65
+ debug ( e )
66
+ return
67
+ }
68
+
69
+ Promise . all ( files . map ( ( file ) => IPFS . files . cp ( [ `/ipfs/${ file . hash } ` , `/${ file . name } ` ] ) ) )
70
+ . then ( ( ) => {
71
+ fs . unlinkSync ( path )
72
+ } )
73
+ . catch ( ( e ) => {
74
+ fs . unlinkSync ( path )
75
+ debug ( e )
76
+ } )
77
+ }
78
+
51
79
function onStartDaemon ( node ) {
52
80
debug ( 'Starting daemon' )
53
81
updateState ( 'starting' )
@@ -99,6 +127,9 @@ function onStartDaemon (node) {
99
127
} )
100
128
}
101
129
130
+ // Move files from V0.3.0
131
+ moveFilesOver ( )
132
+
102
133
menubar . tray . setImage ( config . logo . ice )
103
134
updateState ( 'running' )
104
135
} )
You can’t perform that action at this time.
0 commit comments