createOrUpdateSync method

  1. @override
void createOrUpdateSync(
  1. ItemWithId input
)
override

Creates an item if it doesn't exist, or updates it if it does.

Implementation

@override
void createOrUpdateSync(ItemWithId input) {
  final path = _getItemPath(input.toItemId());

  if (!_lockManagerSync.tryAcquireSync(path)) {
    throw Exception('Unable to acquire lock for $path');
  }

  try {
    _workDbInternalSync.writeFileSync(path, Item(item: input.item));
  } finally {
    _lockManagerSync.releaseSync(path);
  }

  _enforceCollectionLimitSync(input.collection);
}