mirror of
https://github.com/immich-app/immich
synced 2026-08-15 13:03:57 +00:00
move to freezed and slice http batching
This commit is contained in:
parent
de28149d7d
commit
df060eec4f
2 changed files with 25 additions and 37 deletions
|
|
@ -1,3 +1,7 @@
|
|||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'asset_metadata.model.freezed.dart';
|
||||
|
||||
enum RemoteAssetMetadataKey {
|
||||
mobileApp("mobile-app");
|
||||
|
||||
|
|
@ -23,40 +27,24 @@ class RemoteAssetMetadataItem {
|
|||
}
|
||||
}
|
||||
|
||||
class RemoteAssetMobileAppMetadata extends RemoteAssetMetadataValue {
|
||||
final String? cloudId;
|
||||
final String? createdAt;
|
||||
final String? adjustmentTime;
|
||||
final String? latitude;
|
||||
final String? longitude;
|
||||
@freezed
|
||||
abstract class RemoteAssetMobileAppMetadata extends RemoteAssetMetadataValue with _$RemoteAssetMobileAppMetadata {
|
||||
const factory RemoteAssetMobileAppMetadata({
|
||||
String? cloudId,
|
||||
String? createdAt,
|
||||
String? adjustmentTime,
|
||||
String? latitude,
|
||||
String? longitude,
|
||||
}) = _RemoteAssetMobileAppMetadata;
|
||||
|
||||
const RemoteAssetMobileAppMetadata({
|
||||
this.cloudId,
|
||||
this.createdAt,
|
||||
this.adjustmentTime,
|
||||
this.latitude,
|
||||
this.longitude,
|
||||
});
|
||||
const RemoteAssetMobileAppMetadata._();
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, Object?>{};
|
||||
if (cloudId != null) {
|
||||
map["iCloudId"] = cloudId;
|
||||
}
|
||||
if (createdAt != null) {
|
||||
map["createdAt"] = createdAt;
|
||||
}
|
||||
if (adjustmentTime != null) {
|
||||
map["adjustmentTime"] = adjustmentTime;
|
||||
}
|
||||
if (latitude != null) {
|
||||
map["latitude"] = latitude;
|
||||
}
|
||||
if (longitude != null) {
|
||||
map["longitude"] = longitude;
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
Map<String, dynamic> toJson() => {
|
||||
'iCloudId': ?cloudId,
|
||||
'createdAt': ?createdAt,
|
||||
'adjustmentTime': ?adjustmentTime,
|
||||
'latitude': ?latitude,
|
||||
'longitude': ?longitude,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import 'dart:async';
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
|
|
@ -115,12 +115,12 @@ Future<void> _processCloudIdMappingsInBatches(
|
|||
|
||||
if (items.isNotEmpty) {
|
||||
if (canBulkUpdate) {
|
||||
for (int i = 0; i < items.length; i += _kUploadBatchSize) {
|
||||
for (final batch in items.slices(_kUploadBatchSize)) {
|
||||
if (cancellation.isCompleted) {
|
||||
break;
|
||||
}
|
||||
final end = math.min(i + _kUploadBatchSize, items.length);
|
||||
await _bulkUpdate(assetsApi, items.sublist(i, end), cancellation.future);
|
||||
|
||||
await _bulkUpdate(assetsApi, batch, cancellation.future);
|
||||
}
|
||||
} else {
|
||||
await _sequentialUpdate(assetsApi, items, cancellation);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue