I seem to have hit a wall trying to use IDBFS for persistent storage -- 
quite possibly due to my abysmal ignorance of emscripten subtleties, so any 
advice would be very welcome.

My C app has a setup routine which, stripped to the essentials, looks like 
this:

char *setup(char *type)
{
  if (strcmp(type, "SYNCED") != 0)
  {
    EM_ASM(
      FS.mkdir('/data');
      FS.mount(IDBFS, {}, '/data');
      FS.chdir('/data');
      FS.syncfs(true, function(err)
      {
        if(err) alert('ERROR! ' + err);
        else { ccall (setup, 'SYNCED'); }
      });
    );
#ifdef DELAY
    EM_ASM( alert('SETUP proceeding...'); );
#endif /* DELAY */
     [ Open and read pre-existing data file ]
  }
  else
  {  [Do some other stuff ] }  
   return [a result string pointer];  
}

As you see, this code allows for the async nature of the FS.synfs() call, 
but the program fails to find the pre-existing file unless a delay is 
introduced by, e.g., activating the alert call in the above. With such a 
delay all works as I would expect. It very much looks like the FS.sync 
callback is triggered immediately, without waiting for the actual 
synchronisation to take place.

Am I missing something? If so, what? Any suggestions gratefully received.

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to