From 9a8e30681b5f2e356c2c10348403e19db706b2b2 Mon Sep 17 00:00:00 2001 From: Pritesh Nandgaonkar Date: Thu, 14 Feb 2019 04:50:34 -0800 Subject: [PATCH] Handle the case of Logs not being present Summary: - handles the case when log is not present - solved the cpu plugin error - now `fileversion` is the flipper version Reviewed By: jknoxville, danielbuechele Differential Revision: D14065882 fbshipit-source-id: f88414bbb3d766f8ab6e0ec00943b59738918a0e --- src/utils/exportData.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/utils/exportData.js b/src/utils/exportData.js index 3ec6731c4..1b4eb1277 100644 --- a/src/utils/exportData.js +++ b/src/utils/exportData.js @@ -18,9 +18,10 @@ import {default as Client} from '../Client'; import {getInstance} from '../fb-stubs/Logger.js'; import fs from 'fs'; import uuid from 'uuid'; +import {remote} from 'electron'; export type ExportType = {| - fileVersion: '1.0.0', + fileVersion: string, clients: Array, device: ?DeviceExport, store: { @@ -126,7 +127,7 @@ const addSaltToDeviceSerial = ( return {...notif, client: notif.client.replace(serial, newSerial)}; }); return { - fileVersion: '1.0.0', + fileVersion: remote.app.getVersion(), clients: updatedClients, device: newDevice.toJSON(), store: { @@ -216,11 +217,13 @@ export const importFileToStore = (file: string, store: Store) => { } const json = JSON.parse(data); const {device, clients} = json; - const updatedLogs = device.logs.map(log => { - // During the export, Date is exported as string - return {...log, date: new Date(log.date)}; - }); - const {serial, deviceType, title, os} = device; + const {serial, deviceType, title, os, logs} = device; + const updatedLogs = logs + ? logs.map(log => { + // During the export, Date is exported as string + return {...log, date: new Date(log.date)}; + }) + : []; const archivedDevice = new ArchivedDevice( serial, deviceType,