mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
chore: add always_put_control_body_on_new_line lint (#28352)
Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
@@ -18,7 +18,9 @@ String formatBytes(int bytes) {
|
||||
}
|
||||
|
||||
String formatHumanReadableBytes(int bytes, int decimals) {
|
||||
if (bytes <= 0) return "0 B";
|
||||
if (bytes <= 0) {
|
||||
return "0 B";
|
||||
}
|
||||
const suffixes = ["B", "KiB", "MiB", "GiB", "TiB"];
|
||||
var i = (log(bytes) / log(1024)).floor();
|
||||
return '${(bytes / pow(1024, i)).toStringAsFixed(decimals)} ${suffixes[i]}';
|
||||
|
||||
@@ -32,10 +32,14 @@ Future<void> migrateDatabaseIfNeeded(Drift drift) async {
|
||||
|
||||
Future<void> _migrateTo25() async {
|
||||
final accessToken = Store.tryGet(StoreKey.accessToken);
|
||||
if (accessToken == null || accessToken.isEmpty) return;
|
||||
if (accessToken == null || accessToken.isEmpty) {
|
||||
return;
|
||||
}
|
||||
|
||||
final serverUrls = ApiService.getServerUrls();
|
||||
if (serverUrls.isEmpty) return;
|
||||
if (serverUrls.isEmpty) {
|
||||
return;
|
||||
}
|
||||
|
||||
await NetworkRepository.setHeaders(ApiService.getRequestHeaders(), serverUrls, token: accessToken);
|
||||
}
|
||||
@@ -79,7 +83,9 @@ class _StoreMigrator {
|
||||
|
||||
Future<void> migrateEnumIndex<T extends Enum>(StoreKey<int> legacyKey, MetadataKey<T> newKey, List<T> values) async {
|
||||
final index = await readLegacyStoreInt(legacyKey.id);
|
||||
if (index == null) return;
|
||||
if (index == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final enumValue = values.elementAtOrNull(index) ?? newKey.defaultValue;
|
||||
_cache[newKey] = enumValue;
|
||||
@@ -92,7 +98,9 @@ class _StoreMigrator {
|
||||
List<T> values,
|
||||
) async {
|
||||
final name = await readLegacyStoreString(legacyKey.id);
|
||||
if (name == null) return;
|
||||
if (name == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final enumValue = values.firstWhere((e) => e.name == name, orElse: () => newKey.defaultValue);
|
||||
_cache[newKey] = enumValue;
|
||||
@@ -101,7 +109,9 @@ class _StoreMigrator {
|
||||
|
||||
Future<void> migrateBool(StoreKey<bool> legacyKey, MetadataKey<bool> newKey) async {
|
||||
final intValue = await readLegacyStoreInt(legacyKey.id);
|
||||
if (intValue == null) return;
|
||||
if (intValue == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final boolValue = intValue != 0;
|
||||
_cache[newKey] = boolValue;
|
||||
@@ -110,7 +120,9 @@ class _StoreMigrator {
|
||||
|
||||
Future<void> migrateInt(StoreKey<int> legacyKey, MetadataKey<int> newKey) async {
|
||||
final intValue = await readLegacyStoreInt(legacyKey.id);
|
||||
if (intValue == null) return;
|
||||
if (intValue == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
_cache[newKey] = intValue;
|
||||
_migratedStoreIds.add(legacyKey.id);
|
||||
@@ -140,7 +152,9 @@ class _StoreMigrator {
|
||||
}
|
||||
|
||||
Future<void> deleteLegacyStoreRows(List<int> ids) async {
|
||||
if (ids.isEmpty) return;
|
||||
if (ids.isEmpty) {
|
||||
return;
|
||||
}
|
||||
await (_db.storeEntity.delete()..where((t) => t.id.isIn(ids))).go();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,9 @@ class SemVer {
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
if (identical(this, other)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return other is SemVer && other.major == major && other.minor == minor && other.patch == patch;
|
||||
}
|
||||
|
||||
@@ -42,13 +42,17 @@ String? getServerUrl() {
|
||||
///
|
||||
String punycodeEncodeUrl(String serverUrl) {
|
||||
final serverUri = Uri.tryParse(serverUrl);
|
||||
if (serverUri == null || serverUri.host.isEmpty) return '';
|
||||
if (serverUri == null || serverUri.host.isEmpty) {
|
||||
return '';
|
||||
}
|
||||
|
||||
final encodedHost = Uri.decodeComponent(serverUri.host)
|
||||
.split('.')
|
||||
.map((segment) {
|
||||
// If segment is already ASCII, then return as it is.
|
||||
if (segment.runes.every((c) => c < 0x80)) return segment;
|
||||
if (segment.runes.every((c) => c < 0x80)) {
|
||||
return segment;
|
||||
}
|
||||
return 'xn--${punycodeEncode(segment)}';
|
||||
})
|
||||
.join('.');
|
||||
@@ -75,7 +79,9 @@ String punycodeEncodeUrl(String serverUrl) {
|
||||
///
|
||||
String? punycodeDecodeUrl(String? serverUrl) {
|
||||
final serverUri = serverUrl != null ? Uri.tryParse(serverUrl) : null;
|
||||
if (serverUri == null || serverUri.host.isEmpty) return null;
|
||||
if (serverUri == null || serverUri.host.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final decodedHost = serverUri.host
|
||||
.split('.')
|
||||
|
||||
Reference in New Issue
Block a user