Skip to content

umlaut in directory path throws error #406

@khainke

Description

@khainke

using a path with umlauts (ä,ü,ö) for the directory argument of openStore throws an error. It attempts to create a different directory / umlauts are replaced with other characters.

Why is this relevant?

The application support directory includes the user name. The user name in Windows can include umlauts. The application support directory is the prefered location for such files, i.e. databases like objectbox. Other directories often include the user directory as a part. Therefore, this issue is quite a severe one for Windows support.

Basic info (please complete the following information):

  • ObjectBox version: 1.4.1
  • Flutter/Dart SDK:
Flutter 2.10.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision db747aa133 (8 weeks ago) • 2022-02-09 13:57:35 -0600
Engine • revision ab46186b24
Tools • Dart 2.16.1 • DevTools 2.9.2
  • Null-safety enabled: yes
  • Reproducibility: always
  • OS: Windows 10

Steps to reproduce

final sep = Platform.pathSeparator;
final appSupportDir = await getApplicationSupportDirectory();
final dirPath = '${appSupportDir.absolute.path}${sep}testäüö${sep}objectbox';
await Directory(dirPath).create(recursive: true);
_store = await openStore(
  directory: dirPath,
);

Expected behavior

  • if not already existent, create the directory .../testäüö/objectbox
  • create store / save store to this directory

Current behavior

001-11:29:38.8023 [ERROR] Storage error "No such file or directory" (code 2)
[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: ObjectBoxException: failed to create store: 10199 Could not prepare directory: C:\Users\user\AppData\Roaming\com.example\objectbox_test\testäüö\objectbox (2)
#0      ObjectBoxNativeError.throwMapped (package:objectbox/src/native/bindings/helpers.dart:78:9)
#1      throwLatestNativeError (package:objectbox/src/native/bindings/helpers.dart:50:48)
#2      checkObxPtr (package:objectbox/src/native/bindings/helpers.dart:32:5)
#3      Store._checkStorePointer (package:objectbox/src/native/store.dart:285:7)
#4      new Store (package:objectbox/src/native/store.dart:147:7)
#5      openStore (package:objectbox_test/objectbox.g.dart:95:5)
#6      ObjectBoxService.init (package:objectbox_test/objectbox/objectbox_service.dart:26:20)
<asynchronous suspension>
#7      main (package:objectbox_test/main.dart:8:3)
<asynchronous suspension>

Code

main.dart

import 'package:flutter/material.dart';
import 'objectbox/objectbox_service.dart';

import 'main_page/main_page.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await ObjectBoxService.instance.init();
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'ObjectBox Test',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MainPage(),
    );
  }
}
 

objectbox/objectbox_service.dart

import 'dart:io';

import '../objectbox.g.dart';
import 'package:path_provider/path_provider.dart';

class ObjectBoxService {
  ObjectBoxService._internal();

  static final ObjectBoxService _instance = ObjectBoxService._internal();

  factory ObjectBoxService() => ObjectBoxService.instance;

  static ObjectBoxService get instance => _instance;

  late Store _store;

  Store get store => _store;

  /// Initializes this service.
  Future<void> init() async {
    final sep = Platform.pathSeparator;
    final appSupportDir = await getApplicationSupportDirectory();
    final dirPath = '${appSupportDir.absolute.path}${sep}testäüö${sep}objectbox';
    await Directory(dirPath).create(recursive: true);
    _store = await openStore(
      directory: dirPath,
    );
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions