This commit is contained in:
Alex 2025-06-18 13:38:49 -05:00
parent 4b4d1e016b
commit bb6aa56b3e
No known key found for this signature in database
GPG Key ID: 53CD082B3A5E1082
6 changed files with 57 additions and 4 deletions

View File

@ -55,6 +55,27 @@ class ExpBackupPage extends HookConsumerWidget {
),
).tr(),
),
OutlinedButton(
onPressed: () =>
ref.read(expBackupProvider.notifier).getDataInfo(),
child: const Text(
"Get database info",
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
),
).tr(),
),
ElevatedButton(
onPressed: () => ref.read(expBackupProvider.notifier).resume(),
child: const Text(
"Resume",
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
),
).tr(),
),
],
),
);

View File

@ -102,11 +102,11 @@ class ShareIntentUploadStateNotifier
case TaskStatus.complete:
if (update.responseStatusCode == 200) {
if (kDebugMode) {
debugPrint("[COMPLETE] ${update.task.taskId} - DUPLICATE");
// debugPrint("[COMPLETE] ${update.task.taskId} - DUPLICATE");
}
} else {
if (kDebugMode) {
debugPrint("[COMPLETE] ${update.task.taskId}");
// debugPrint("[COMPLETE] ${update.task.taskId}");
}
}
break;

View File

@ -5,6 +5,7 @@ import 'dart:convert';
import 'package:background_downloader/background_downloader.dart';
import 'package:collection/collection.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:immich_mobile/constants/constants.dart';
import 'package:immich_mobile/services/exp_backup.service.dart';
import 'package:immich_mobile/services/upload.service.dart';
@ -222,6 +223,23 @@ class ExpBackupNotifier extends StateNotifier<ExpBackupState> {
return _backupService.cancel();
}
Future<void> getDataInfo() async {
final a = await FileDownloader().database.allRecordsWithStatus(
TaskStatus.enqueued,
group: kBackupGroup,
);
final b = await FileDownloader().allTasks(
group: kBackupGroup,
);
print("ALl tasks: ${b.length}");
}
Future<void> resume() async {
await FileDownloader().start();
}
@override
void dispose() {
_statusSubscription?.cancel();

View File

@ -15,8 +15,11 @@ class UploadRepository implements IUploadRepository {
final taskQueue = MemoryTaskQueue();
UploadRepository() {
taskQueue.minInterval = const Duration(milliseconds: 5);
taskQueue.minInterval = const Duration(milliseconds: 25);
taskQueue.maxConcurrent = 5;
taskQueue.maxConcurrentByHost = 5;
taskQueue.maxConcurrentByGroup = 5;
FileDownloader().addTaskQueue(taskQueue);
FileDownloader().registerCallbacks(
group: kBackupGroup,
@ -28,6 +31,12 @@ class UploadRepository implements IUploadRepository {
taskStatusCallback: (update) => onUploadStatus?.call(update),
taskProgressCallback: (update) => onTaskProgress?.call(update),
);
taskQueue.enqueueErrors.listen((error) {
// Handle errors from the task queue
// You can log them or take appropriate actions
print('Task Queue Error: $error');
});
}
@override

View File

@ -66,7 +66,7 @@ class ExpBackupService {
return;
}
const batchSize = 5;
const batchSize = 100;
for (int i = 0; i < candidates.length; i += batchSize) {
if (shouldCancel) {
break;
@ -200,6 +200,7 @@ class ExpBackupService {
deviceAssetId: asset.id,
fields: fields,
group: kBackupLivePhotoGroup,
priority: 0,
);
}

View File

@ -86,6 +86,7 @@ class UploadService {
String? originalFileName,
String? deviceAssetId,
String? metadata,
int? priority,
}) async {
return _buildTask(
deviceAssetId ?? hash(file.path).toString(),
@ -94,6 +95,7 @@ class UploadService {
originalFileName: originalFileName,
metadata: metadata,
group: group,
priority: priority,
);
}
@ -104,6 +106,7 @@ class UploadService {
Map<String, String>? fields,
String? originalFileName,
String? metadata,
int? priority,
}) async {
final serverEndpoint = Store.get(StoreKey.serverEndpoint);
final url = Uri.parse('$serverEndpoint/assets').toString();
@ -139,6 +142,7 @@ class UploadService {
fileField: 'assetData',
metaData: metadata ?? '',
group: group,
priority: priority ?? 5,
updates: Updates.statusAndProgress,
);
}