From bca86d4d538edab140f856715d6b066245a99886 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 24 Sep 2019 10:19:50 +0200 Subject: [PATCH 1/2] migrate file system --- src/app.js | 7 +++++-- src/migrateFileSystem.js | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 src/migrateFileSystem.js diff --git a/src/app.js b/src/app.js index 36c14f75b5..29aed3e1b9 100644 --- a/src/app.js +++ b/src/app.js @@ -49,6 +49,8 @@ import { LandingPage } from './app/ui/landing-page/landing-page' import { MainPanel } from './app/components/main-panel' import { UniversalDApp } from 'remix-lib' +import migrateFileSystem from './migrateFileSystem' + var css = csjs` html { box-sizing: border-box; } *, *:before, *:after { box-sizing: inherit; } @@ -102,7 +104,6 @@ class App { var self = this self._components = {} // setup storage - var fileStorage = new Storage('sol:') var configStorage = new Storage('config-v0.8:') // load app config @@ -111,7 +112,7 @@ class App { // load file system self._components.filesProviders = {} - self._components.filesProviders['browser'] = new FileProvider('browser', fileStorage) + self._components.filesProviders['browser'] = new FileProvider('browser') registry.put({api: self._components.filesProviders['browser'], name: 'fileproviders/browser'}) var remixd = new Remixd(65520) @@ -125,6 +126,8 @@ class App { registry.put({api: self._components.filesProviders, name: 'fileproviders'}) self._view = {} + + migrateFileSystem(self._components.filesProviders['browser']) } init () { diff --git a/src/migrateFileSystem.js b/src/migrateFileSystem.js new file mode 100644 index 0000000000..fbc35ff6ed --- /dev/null +++ b/src/migrateFileSystem.js @@ -0,0 +1,15 @@ + +import { Storage } from 'remix-lib' + +export default (fileProvider) => { + const fileStorage = new Storage('sol:') + if (fileStorage.keys().length === 0) return + fileStorage.keys().forEach((path) => { + if (path !== '.remix.config') { + const content = fileStorage.get(path) + fileProvider.set(path, content) + fileStorage.remove(path) + console.log('file migrated', path) + } + }) +} From 38c934094b7cb744efdabed1273b3b72f65116d7 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 25 Sep 2019 09:50:35 +0200 Subject: [PATCH 2/2] added comment --- src/migrateFileSystem.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/migrateFileSystem.js b/src/migrateFileSystem.js index fbc35ff6ed..d72a11da6b 100644 --- a/src/migrateFileSystem.js +++ b/src/migrateFileSystem.js @@ -1,6 +1,9 @@ import { Storage } from 'remix-lib' +/* + Migrating the files to the BrowserFS storage instead or raw localstorage +*/ export default (fileProvider) => { const fileStorage = new Storage('sol:') if (fileStorage.keys().length === 0) return