Update stat data on flush and not for each write

This should greatly reduce the number of IndexedDB transactions we create.
The *stat* function should also return *openedFiles[fd].stat* if it exists. Otherwise it'll return an out-of-date stat for an open file that has been written to but not flushed.