renameAsync method

Future<StoreDirectory> renameAsync(
  1. String storeName
)

Rename the store directory asynchronously

The old StoreDirectory will still retain it's link to the old store, so always use the new returned value instead: returns a new StoreDirectory after a successful renaming operation.

Implementation

Future<StoreDirectory> renameAsync(String storeName) async {
  final String safe = filesystemSanitiseValidate(
    inputString: storeName,
    throwIfInvalid: true,
  );

  if (safe != _storeDirectory.storeName) {
    await _access.real.rename(
      p.joinAll([_storeDirectory.rootDirectory.access.stores.path, safe]),
    );
  }

  return _storeDirectory.copyWith(storeName: safe);
}