File tree Expand file tree Collapse file tree 3 files changed +17
-9
lines changed Expand file tree Collapse file tree 3 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -60,11 +60,21 @@ export function mount() {
6060 Module . FS . mount ( Module . IDBFS , { autoPersist : true } , HOME_MOUNT_POINT )
6161}
6262
63- export function reset ( ) {
63+ export function sync ( direction : 'load' | 'save' ) {
6464 const { promise, resolve } = Promise . withResolvers < void > ( )
65+ Module . FS . syncfs ( direction === 'load' , ( err ) => {
66+ if ( err ) {
67+ console . error ( err )
68+ }
69+ // Before better understanding possible errors, don't break core functionalities, which don't rely on IDBFS.
70+ resolve ( )
71+ } )
72+ return promise
73+ }
74+
75+ export function reset ( ) {
6576 rmR ( USR_MOUNT_POINT )
6677 rmR ( HOME_MOUNT_POINT )
6778 // Manually trigger syncfs to ensure data is cleared.
68- Module . FS . syncfs ( false , ( ) => resolve ( ) )
69- return promise
79+ return sync ( 'save' )
7080}
Original file line number Diff line number Diff line change @@ -184,10 +184,7 @@ for (const api of apis) {
184184
185185Module . onRuntimeInitialized = ( ) => {
186186 mount ( )
187- Module . FS . syncfs ( true , ( ) => {
188- restorePlugins ( )
189- resolve ( null )
190- } )
187+ restorePlugins ( ) . then ( resolve )
191188}
192189
193190export {
Original file line number Diff line number Diff line change 11import UZIP from 'uzip'
22import { hasTouch } from './context'
3- import { lsDir , traverseSync , USR_MOUNT_POINT } from './fs'
3+ import { lsDir , sync , traverseSync , USR_MOUNT_POINT } from './fs'
44import { getLocale } from './locale'
55import Module from './module'
66
@@ -77,7 +77,8 @@ export function installPlugin(buffer: ArrayBuffer) {
7777}
7878
7979// Symlink all plugins' files from /backup/usr to /usr.
80- export function restorePlugins ( ) {
80+ export async function restorePlugins ( ) {
81+ await sync ( 'load' )
8182 traverseSync ( ( backupPath ) => {
8283 const path = `/usr${ backupPath . slice ( USR_MOUNT_POINT . length ) } `
8384 Module . FS . mkdirTree ( path )
You can’t perform that action at this time.
0 commit comments