Skip to content

Commit

Permalink
Merge pull request #187 from Piwigo/feature/remove_parallel_upload
Browse files Browse the repository at this point in the history
Remove parallel upload
  • Loading branch information
remi-martin authored Jun 24, 2024
2 parents e608898 + fca897d commit 12a2192
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions lib/network/upload.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ Future<List<int>> uploadPhotos(
if (url == null) return [];
String? username = await storage.read(key: Preferences.usernameKey);
String? password = await storage.read(key: Preferences.passwordKey);
UploadNotifier uploadNotifier =
App.appKey.currentContext!.read<UploadNotifier>();
UploadNotifier uploadNotifier = App.appKey.currentContext!.read<UploadNotifier>();
int nbError = 0;

// Creates Upload Item list for the upload notifier
Expand All @@ -106,8 +105,7 @@ Future<List<int>> uploadPhotos(
App.navigatorKey.currentState?.popAndPushNamed(UploadStatusPage.routeName);

// Iterate on each item
await Future.wait(List<Future<void>>.generate(items.length, (index) async {
UploadItem item = items[index];
for (UploadItem item in items) {
try {
// Upload image
Response? response = await uploadChunk(
Expand Down Expand Up @@ -152,7 +150,7 @@ Future<List<int>> uploadPhotos(
uploadNotifier.itemUploadCompleted(item, error: true);
nbError++;
}
}));
}

// Send notifications
showUploadNotification(nbError, result.length);
Expand Down Expand Up @@ -202,10 +200,8 @@ Future<Response?> uploadChunk({

// Filter fields
if (info['name'] != '' && info['name'] != null) fields['name'] = info['name'];
if (info['comment'] != '' && info['comment'] != null)
fields['comment'] = info['comment'];
if (info['tag_ids']?.isNotEmpty ?? false)
fields['tag_ids'] = info['tag_ids'].join(',');
if (info['comment'] != '' && info['comment'] != null) fields['comment'] = info['comment'];
if (info['tag_ids']?.isNotEmpty ?? false) fields['tag_ids'] = info['tag_ids'].join(',');
if (info['level'] != -1) fields['level'] = info['level'];

// Create dio client
Expand Down Expand Up @@ -247,8 +243,7 @@ Future<bool> uploadCompleted(List<int> imageId, int categoryId) async {
});

try {
Response response =
await ApiClient.post(data: formData, queryParameters: queries);
Response response = await ApiClient.post(data: formData, queryParameters: queries);
if (response.statusCode == 200) {
return true;
}
Expand All @@ -270,8 +265,7 @@ Future<bool> communityUploadCompleted(List<int> imageId, int categoryId) async {
'category_id': categoryId,
});
try {
Response response =
await ApiClient.post(data: formData, queryParameters: queries);
Response response = await ApiClient.post(data: formData, queryParameters: queries);
if (response.statusCode == 200) {
return true;
}
Expand Down

0 comments on commit 12a2192

Please sign in to comment.