1
1
const extract = require ( 'extract-zip' ) ;
2
2
const _ = require ( 'lodash' ) ;
3
- const { promisify } = require ( 'util' ) ;
4
3
const fs = require ( 'fs' ) ;
5
4
const ObjectId = require ( 'bson-objectid' ) ;
6
5
const { VAR_FOLDER } = require ( '../config/config' ) ;
@@ -54,7 +53,7 @@ const renameSpaceFolder = async (prevPath, newPath) => {
54
53
return wasRenamed ;
55
54
} ;
56
55
57
- const extractFileToLoadSpace = mainWindow => async (
56
+ const extractFileToLoadSpace = ( mainWindow ) => async (
58
57
event ,
59
58
{ fileLocation }
60
59
) => {
@@ -63,7 +62,7 @@ const extractFileToLoadSpace = mainWindow => async (
63
62
// make temporary folder hidden
64
63
const extractPath = `${ VAR_FOLDER } /.${ tmpId } ` ;
65
64
try {
66
- await promisify ( extract ) ( fileLocation , { dir : extractPath } ) ;
65
+ await extract ( fileLocation , { dir : extractPath } ) ;
67
66
68
67
// get basic information from manifest
69
68
const manifestPath = `${ extractPath } /manifest.json` ;
@@ -102,7 +101,7 @@ const extractFileToLoadSpace = mainWindow => async (
102
101
}
103
102
} ;
104
103
105
- const clearLoadSpace = mainWindow => async ( event , { extractPath } ) => {
104
+ const clearLoadSpace = ( mainWindow ) => async ( event , { extractPath } ) => {
106
105
const isCleanSuccessful = clean ( extractPath ) ;
107
106
mainWindow . webContents . send ( CLEAR_LOAD_SPACE_CHANNEL ) ;
108
107
return isCleanSuccessful ;
@@ -158,9 +157,7 @@ const loadSpace = (mainWindow, db) => async (
158
157
deleteSpaceAndResources ( db , id , tmpPath ) ;
159
158
160
159
// add new space in database
161
- db . get ( SPACES_COLLECTION )
162
- . push ( space )
163
- . write ( ) ;
160
+ db . get ( SPACES_COLLECTION ) . push ( space ) . write ( ) ;
164
161
} else {
165
162
// clean temp space folder
166
163
clean ( extractPath ) ;
@@ -181,7 +178,7 @@ const loadSpace = (mainWindow, db) => async (
181
178
// keep only non-duplicate resources
182
179
. filter ( ( { id } ) => ! savedResources . find ( { id } ) . value ( ) )
183
180
// change user id by current user id
184
- . map ( resource => ( {
181
+ . map ( ( resource ) => ( {
185
182
...resource ,
186
183
user : userId ,
187
184
} ) ) ;
@@ -202,7 +199,7 @@ const loadSpace = (mainWindow, db) => async (
202
199
// keep only non-duplicate actions
203
200
. filter ( ( { id } ) => ! savedActions . find ( { id } ) . value ( ) )
204
201
// change user id by current user id
205
- . map ( action => ( { ...action , user : userId } ) ) ;
202
+ . map ( ( action ) => ( { ...action , user : userId } ) ) ;
206
203
207
204
savedActions . push ( ...newActions ) . write ( ) ;
208
205
}
0 commit comments