fsIdbImport function

Future<void> fsIdbImport(
  1. FileSystem fs,
  2. Object data
)

Copy a database export to another

return the opened database

Implementation

Future<void> fsIdbImport(FileSystem fs, Object data) async {
  var newIdbFactory = newIdbFactoryMemory();
  var dbName = 'fs';
  // Import and close
  var idbDatabase = await idbImportDatabase(data, newIdbFactory, dbName);
  idbDatabase.close();
  // Reopen as a file system
  var importFs = newFileSystemIdb(newIdbFactory, dbName);
  if (await importFs.currentDirectory.exists()) {
    await copyDirectory(
      importFs.currentDirectory,
      fs.currentDirectory,
      options: CopyOptions(recursive: true),
    );
  }
}