Skip to content

Commit 12a2192

Browse files
authored
Merge pull request #187 from Piwigo/feature/remove_parallel_upload
Remove parallel upload
2 parents e608898 + fca897d commit 12a2192

1 file changed

Lines changed: 7 additions & 13 deletions

File tree

lib/network/upload.dart

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ Future<List<int>> uploadPhotos(
8585
if (url == null) return [];
8686
String? username = await storage.read(key: Preferences.usernameKey);
8787
String? password = await storage.read(key: Preferences.passwordKey);
88-
UploadNotifier uploadNotifier =
89-
App.appKey.currentContext!.read<UploadNotifier>();
88+
UploadNotifier uploadNotifier = App.appKey.currentContext!.read<UploadNotifier>();
9089
int nbError = 0;
9190

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

108107
// Iterate on each item
109-
await Future.wait(List<Future<void>>.generate(items.length, (index) async {
110-
UploadItem item = items[index];
108+
for (UploadItem item in items) {
111109
try {
112110
// Upload image
113111
Response? response = await uploadChunk(
@@ -152,7 +150,7 @@ Future<List<int>> uploadPhotos(
152150
uploadNotifier.itemUploadCompleted(item, error: true);
153151
nbError++;
154152
}
155-
}));
153+
}
156154

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

203201
// Filter fields
204202
if (info['name'] != '' && info['name'] != null) fields['name'] = info['name'];
205-
if (info['comment'] != '' && info['comment'] != null)
206-
fields['comment'] = info['comment'];
207-
if (info['tag_ids']?.isNotEmpty ?? false)
208-
fields['tag_ids'] = info['tag_ids'].join(',');
203+
if (info['comment'] != '' && info['comment'] != null) fields['comment'] = info['comment'];
204+
if (info['tag_ids']?.isNotEmpty ?? false) fields['tag_ids'] = info['tag_ids'].join(',');
209205
if (info['level'] != -1) fields['level'] = info['level'];
210206

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

249245
try {
250-
Response response =
251-
await ApiClient.post(data: formData, queryParameters: queries);
246+
Response response = await ApiClient.post(data: formData, queryParameters: queries);
252247
if (response.statusCode == 200) {
253248
return true;
254249
}
@@ -270,8 +265,7 @@ Future<bool> communityUploadCompleted(List<int> imageId, int categoryId) async {
270265
'category_id': categoryId,
271266
});
272267
try {
273-
Response response =
274-
await ApiClient.post(data: formData, queryParameters: queries);
268+
Response response = await ApiClient.post(data: formData, queryParameters: queries);
275269
if (response.statusCode == 200) {
276270
return true;
277271
}

0 commit comments

Comments
 (0)