handleQuota method

Future<void> handleQuota()

Implementation

Future<void> handleQuota() async {
  await _prepareClient();
  try {
    final response = await client.api.makeRequest(
      'GET',
      Uri.parse('${FilenClient.apiUrl}/v3/user/info'),
    );
    final data = json.decode(response.body);
    if (data['status'] == true && data['data'] != null) {
      final info = data['data'];
      final used = info['storageUsed'] ?? 0;
      final max = info['maxStorage'] ?? 0;
      final pct = max > 0 ? (used / max * 100).toStringAsFixed(1) : '?';
      print('\ud83d\udcca Storage Quota:');
      print('   Used:  ${formatSize(used)}');
      print('   Total: ${formatSize(max)}');
      print('   Usage: $pct%');
    } else {
      print('\u274c Could not fetch quota info');
    }
  } catch (e) {
    _exit('Quota failed: $e');
  }
}