validateStorage static method

(bool, String?) validateStorage([
  1. StorageType? type
])

Validate storage configuration

验证存储配置

type 要验证的存储类型,如果为null则验证默认类型

返回验证结果和错误信息

Implementation

static (bool isValid, String? errorMessage) validateStorage(
    [StorageType? type]) {
  if (_storageConfig == null) {
    const msg = 'Storage configuration is not set';
    loge('validateStorage failed: $msg');
    return (false, msg);
  }

  final targetType = type ?? _defaultStorageType;
  final basePath = getBasePath(targetType);

  if (basePath == null || basePath.isEmpty) {
    final msg = 'Storage path for type $targetType is not set';
    loge('validateStorage failed: $msg');
    return (false, msg);
  }

  return (true, null);
}