Skip to content

Commit

Permalink
build: update archiver, history, extract-zip
Browse files Browse the repository at this point in the history
  • Loading branch information
pyphilia committed Oct 1, 2020
1 parent bd0e104 commit 64dc25b
Show file tree
Hide file tree
Showing 3 changed files with 174 additions and 201 deletions.
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"prebuild": "env-cmd -f ./.env node scripts/setup.js",
"predist": "yarn build",
"predist:win": "yarn build",
"predist:mac": "yarn build",
"predist:linux": "yarn build",
"predist:posix": "yarn build",
"prerelease": "yarn test:once && yarn build",
Expand Down Expand Up @@ -72,26 +71,26 @@
"@material-ui/core": "4.11.0",
"@material-ui/icons": "4.9.1",
"@sentry/browser": "5.24.2",
"@sentry/electron": "1.4.0",
"@sentry/electron": "2.0.1",
"about-window": "1.13.4",
"archiver": "3.1.1",
"archiver": "5.0.2",
"bson-objectid": "1.3.1",
"chai": "4.2.0",
"cheerio": "1.0.0-rc.3",
"classnames": "2.2.6",
"clsx": "1.1.1",
"connected-react-router": "6.8.0",
"download": "7.1.0",
"download": "8.0.0",
"electron-devtools-installer": "2.2.4",
"electron-is-dev": "1.2.0",
"electron-log": "4.2.4",
"electron-publisher-s3": "20.17.2",
"electron-updater": "4.3.5",
"enzyme": "3.11.0",
"enzyme-adapter-react-16": "1.15.5",
"extract-zip": "1.6.7",
"extract-zip": "2.0.1",
"fs-extra": "9.0.1",
"history": "4.10.1",
"history": "5.0.0",
"i18next": "19.7.0",
"immutable": "4.0.0-rc.12",
"is-online": "8.4.0",
Expand Down
15 changes: 6 additions & 9 deletions public/app/listeners/loadSpace.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const extract = require('extract-zip');
const _ = require('lodash');
const { promisify } = require('util');
const fs = require('fs');
const ObjectId = require('bson-objectid');
const { VAR_FOLDER } = require('../config/config');
Expand Down Expand Up @@ -54,7 +53,7 @@ const renameSpaceFolder = async (prevPath, newPath) => {
return wasRenamed;
};

const extractFileToLoadSpace = mainWindow => async (
const extractFileToLoadSpace = (mainWindow) => async (
event,
{ fileLocation }
) => {
Expand All @@ -63,7 +62,7 @@ const extractFileToLoadSpace = mainWindow => async (
// make temporary folder hidden
const extractPath = `${VAR_FOLDER}/.${tmpId}`;
try {
await promisify(extract)(fileLocation, { dir: extractPath });
await extract(fileLocation, { dir: extractPath });

// get basic information from manifest
const manifestPath = `${extractPath}/manifest.json`;
Expand Down Expand Up @@ -102,7 +101,7 @@ const extractFileToLoadSpace = mainWindow => async (
}
};

const clearLoadSpace = mainWindow => async (event, { extractPath }) => {
const clearLoadSpace = (mainWindow) => async (event, { extractPath }) => {
const isCleanSuccessful = clean(extractPath);
mainWindow.webContents.send(CLEAR_LOAD_SPACE_CHANNEL);
return isCleanSuccessful;
Expand Down Expand Up @@ -158,9 +157,7 @@ const loadSpace = (mainWindow, db) => async (
deleteSpaceAndResources(db, id, tmpPath);

// add new space in database
db.get(SPACES_COLLECTION)
.push(space)
.write();
db.get(SPACES_COLLECTION).push(space).write();
} else {
// clean temp space folder
clean(extractPath);
Expand All @@ -181,7 +178,7 @@ const loadSpace = (mainWindow, db) => async (
// keep only non-duplicate resources
.filter(({ id }) => !savedResources.find({ id }).value())
// change user id by current user id
.map(resource => ({
.map((resource) => ({
...resource,
user: userId,
}));
Expand All @@ -202,7 +199,7 @@ const loadSpace = (mainWindow, db) => async (
// keep only non-duplicate actions
.filter(({ id }) => !savedActions.find({ id }).value())
// change user id by current user id
.map(action => ({ ...action, user: userId }));
.map((action) => ({ ...action, user: userId }));

savedActions.push(...newActions).write();
}
Expand Down
Loading

0 comments on commit 64dc25b

Please sign in to comment.