-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fe58113
commit 32a1770
Showing
20 changed files
with
4,883 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"yaml.schemas": { | ||
"https://json.schemastore.org/dart-build": [ | ||
"build.yaml", | ||
"*.build.yaml", | ||
"build.*.yaml" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
targets: | ||
$default: | ||
builders: | ||
drift_dev: | ||
enabled: false | ||
drift_dev:analyzer: | ||
enabled: true | ||
options: &options | ||
named_parameters: true | ||
store_date_time_values_as_text: true | ||
drift_dev:modular: | ||
enabled: true | ||
options: *options |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
// Copyright © Luka S (JaffaKetchup) under GPL-v3 | ||
// A full license can be found at .\LICENSE | ||
|
||
import 'dart:async'; | ||
import 'dart:collection'; | ||
import 'dart:convert'; | ||
import 'dart:io'; | ||
import 'dart:isolate'; | ||
import 'dart:math'; | ||
|
||
import 'package:collection/collection.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/services.dart'; | ||
import 'package:meta/meta.dart'; | ||
import 'package:path/path.dart' as path; | ||
import 'package:path_provider/path_provider.dart'; | ||
|
||
import '../../../../../../flutter_map_tile_caching.dart'; | ||
import '../../../../../misc/int_extremes.dart'; | ||
import '../../../../export_internal.dart'; | ||
import '../models/generated/objectbox.g.dart'; | ||
import '../models/src/recovery.dart'; | ||
import '../models/src/recovery_region.dart'; | ||
import '../models/src/root.dart'; | ||
import '../database/models/store.dart'; | ||
import '../models/src/tile.dart'; | ||
|
||
export 'package:objectbox/objectbox.dart' show StorageException; | ||
|
||
part 'internal_workers/standard/cmd_type.dart'; | ||
part 'internal_workers/standard/worker.dart'; | ||
part 'internal_workers/shared.dart'; | ||
part 'internal_workers/thread_safe.dart'; | ||
part 'internal.dart'; | ||
|
||
/// Implementation of [FMTCBackend] that uses ObjectBox as the storage database | ||
/// | ||
/// On web, this redirects to a no-op implementation that throws | ||
/// [UnsupportedError]s when attempting to use [initialise] or [uninitialise], | ||
/// and [RootUnavailable] when trying to use any other method. | ||
final class FMTCObjectBoxBackend implements FMTCBackend { | ||
/// {@macro fmtc.backend.initialise} | ||
/// | ||
/// --- | ||
/// | ||
/// [maxDatabaseSize] is the maximum size the database file can grow | ||
/// to, in KB. Exceeding it throws [DbFullException] (from | ||
/// 'package:objectbox') on write operations. Defaults to 10 GB (10000000 KB). | ||
/// | ||
/// [macosApplicationGroup] should be set when creating a sandboxed macOS app, | ||
/// specify the application group (of less than 20 chars). See | ||
/// [the ObjectBox docs](https://docs.objectbox.io/getting-started) for | ||
/// details. | ||
/// | ||
/// [rootIsolateToken] should only be used in exceptional circumstances where | ||
/// this backend is being initialised in a seperate isolate (or background) | ||
/// thread. | ||
/// | ||
/// Avoid using [useInMemoryDatabase] outside of testing purposes. | ||
@override | ||
Future<void> initialise({ | ||
String? rootDirectory, | ||
int maxDatabaseSize = 10000000, | ||
String? macosApplicationGroup, | ||
RootIsolateToken? rootIsolateToken, | ||
@visibleForTesting bool useInMemoryDatabase = false, | ||
}) => | ||
FMTCObjectBoxBackendInternal._instance.initialise( | ||
rootDirectory: rootDirectory, | ||
maxDatabaseSize: maxDatabaseSize, | ||
macosApplicationGroup: macosApplicationGroup, | ||
useInMemoryDatabase: useInMemoryDatabase, | ||
rootIsolateToken: rootIsolateToken, | ||
); | ||
|
||
/// {@macro fmtc.backend.uninitialise} | ||
/// | ||
/// If [immediate] is `true`, any operations currently underway will be lost, | ||
/// as the worker will be killed as quickly as possible (not necessarily | ||
/// instantly). | ||
/// If `false`, all operations currently underway will be allowed to complete, | ||
/// but any operations started after this method call will be lost. | ||
@override | ||
Future<void> uninitialise({ | ||
bool deleteRoot = false, | ||
bool immediate = false, | ||
}) => | ||
FMTCObjectBoxBackendInternal._instance | ||
.uninitialise(deleteRoot: deleteRoot, immediate: immediate); | ||
} |
Oops, something went wrong.