mirror of
https://github.com/immich-app/immich.git
synced 2025-07-08 10:44:15 -04:00
wip
This commit is contained in:
parent
4b4d1e016b
commit
bb6aa56b3e
@ -55,6 +55,27 @@ class ExpBackupPage extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
).tr(),
|
).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(),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -102,11 +102,11 @@ class ShareIntentUploadStateNotifier
|
|||||||
case TaskStatus.complete:
|
case TaskStatus.complete:
|
||||||
if (update.responseStatusCode == 200) {
|
if (update.responseStatusCode == 200) {
|
||||||
if (kDebugMode) {
|
if (kDebugMode) {
|
||||||
debugPrint("[COMPLETE] ${update.task.taskId} - DUPLICATE");
|
// debugPrint("[COMPLETE] ${update.task.taskId} - DUPLICATE");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (kDebugMode) {
|
if (kDebugMode) {
|
||||||
debugPrint("[COMPLETE] ${update.task.taskId}");
|
// debugPrint("[COMPLETE] ${update.task.taskId}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -5,6 +5,7 @@ import 'dart:convert';
|
|||||||
import 'package:background_downloader/background_downloader.dart';
|
import 'package:background_downloader/background_downloader.dart';
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.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/exp_backup.service.dart';
|
||||||
import 'package:immich_mobile/services/upload.service.dart';
|
import 'package:immich_mobile/services/upload.service.dart';
|
||||||
@ -222,6 +223,23 @@ class ExpBackupNotifier extends StateNotifier<ExpBackupState> {
|
|||||||
return _backupService.cancel();
|
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
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_statusSubscription?.cancel();
|
_statusSubscription?.cancel();
|
||||||
|
@ -15,8 +15,11 @@ class UploadRepository implements IUploadRepository {
|
|||||||
final taskQueue = MemoryTaskQueue();
|
final taskQueue = MemoryTaskQueue();
|
||||||
|
|
||||||
UploadRepository() {
|
UploadRepository() {
|
||||||
taskQueue.minInterval = const Duration(milliseconds: 5);
|
taskQueue.minInterval = const Duration(milliseconds: 25);
|
||||||
taskQueue.maxConcurrent = 5;
|
taskQueue.maxConcurrent = 5;
|
||||||
|
taskQueue.maxConcurrentByHost = 5;
|
||||||
|
taskQueue.maxConcurrentByGroup = 5;
|
||||||
|
|
||||||
FileDownloader().addTaskQueue(taskQueue);
|
FileDownloader().addTaskQueue(taskQueue);
|
||||||
FileDownloader().registerCallbacks(
|
FileDownloader().registerCallbacks(
|
||||||
group: kBackupGroup,
|
group: kBackupGroup,
|
||||||
@ -28,6 +31,12 @@ class UploadRepository implements IUploadRepository {
|
|||||||
taskStatusCallback: (update) => onUploadStatus?.call(update),
|
taskStatusCallback: (update) => onUploadStatus?.call(update),
|
||||||
taskProgressCallback: (update) => onTaskProgress?.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
|
@override
|
||||||
|
@ -66,7 +66,7 @@ class ExpBackupService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const batchSize = 5;
|
const batchSize = 100;
|
||||||
for (int i = 0; i < candidates.length; i += batchSize) {
|
for (int i = 0; i < candidates.length; i += batchSize) {
|
||||||
if (shouldCancel) {
|
if (shouldCancel) {
|
||||||
break;
|
break;
|
||||||
@ -200,6 +200,7 @@ class ExpBackupService {
|
|||||||
deviceAssetId: asset.id,
|
deviceAssetId: asset.id,
|
||||||
fields: fields,
|
fields: fields,
|
||||||
group: kBackupLivePhotoGroup,
|
group: kBackupLivePhotoGroup,
|
||||||
|
priority: 0,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,6 +86,7 @@ class UploadService {
|
|||||||
String? originalFileName,
|
String? originalFileName,
|
||||||
String? deviceAssetId,
|
String? deviceAssetId,
|
||||||
String? metadata,
|
String? metadata,
|
||||||
|
int? priority,
|
||||||
}) async {
|
}) async {
|
||||||
return _buildTask(
|
return _buildTask(
|
||||||
deviceAssetId ?? hash(file.path).toString(),
|
deviceAssetId ?? hash(file.path).toString(),
|
||||||
@ -94,6 +95,7 @@ class UploadService {
|
|||||||
originalFileName: originalFileName,
|
originalFileName: originalFileName,
|
||||||
metadata: metadata,
|
metadata: metadata,
|
||||||
group: group,
|
group: group,
|
||||||
|
priority: priority,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,6 +106,7 @@ class UploadService {
|
|||||||
Map<String, String>? fields,
|
Map<String, String>? fields,
|
||||||
String? originalFileName,
|
String? originalFileName,
|
||||||
String? metadata,
|
String? metadata,
|
||||||
|
int? priority,
|
||||||
}) async {
|
}) async {
|
||||||
final serverEndpoint = Store.get(StoreKey.serverEndpoint);
|
final serverEndpoint = Store.get(StoreKey.serverEndpoint);
|
||||||
final url = Uri.parse('$serverEndpoint/assets').toString();
|
final url = Uri.parse('$serverEndpoint/assets').toString();
|
||||||
@ -139,6 +142,7 @@ class UploadService {
|
|||||||
fileField: 'assetData',
|
fileField: 'assetData',
|
||||||
metaData: metadata ?? '',
|
metaData: metadata ?? '',
|
||||||
group: group,
|
group: group,
|
||||||
|
priority: priority ?? 5,
|
||||||
updates: Updates.statusAndProgress,
|
updates: Updates.statusAndProgress,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user