Skip to content

Commit

Permalink
Merge pull request #1513 from ardriveapp/dev
Browse files Browse the repository at this point in the history
PE-5181: Release App v2.27.0
  • Loading branch information
thiagocarvalhodev authored Dec 6, 2023
2 parents 11a3e2c + 646beec commit 158d137
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 69 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
run: |
scr setup
flutter config --enable-web
flutter build web --dart-define=environment=development --release
flutter build web --dart-define=environment=development --release --pwa-strategy=none --no-web-resources-cdn
# JS files cache invalidation
- name: main.dart.js and service worker cache invalidation
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
run: |
scr setup
flutter config --enable-web
flutter build web --release --dart-define=environment=production
flutter build web --release --dart-define=environment=production --pwa-strategy=none --no-web-resources-cdn
# Disribute to Firebase
- uses: FirebaseExtended/action-hosting-deploy@v0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
run: |
scr setup
flutter config --enable-web
flutter build web --dart-define=environment=staging --release
flutter build web --dart-define=environment=staging --release --pwa-strategy=none --no-web-resources-cdn
# Deploy to github pages
- uses: JamesIves/[email protected]
Expand Down
2 changes: 2 additions & 0 deletions android/fastlane/metadata/android/en-US/changelogs/83.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Fixes Tab-Switch upload failure in Turbo Web App
- Increases the limit of Turbo Uploads to 10GiB
2 changes: 1 addition & 1 deletion lib/blocs/upload/limits.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ int getBundleSizeLimit(bool isTurbo) =>
isTurbo ? turboBundleSizeLimit : d2nBundleSizeLimit;

final d2nBundleSizeLimit = const GiB(65).size;
final turboBundleSizeLimit = const GiB(2).size;
final turboBundleSizeLimit = const GiB(10).size;
final mobileBundleSizeLimit = const GiB(65).size;
const maxBundleDataItemCount = 500;
const maxFilesPerBundle = maxBundleDataItemCount ~/ 2;
Expand Down
10 changes: 0 additions & 10 deletions packages/ardrive_uploader/lib/src/turbo_streamed_upload.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'package:ardrive_uploader/src/streamed_upload.dart';
import 'package:ardrive_uploader/src/turbo_upload_service_base.dart';
import 'package:ardrive_utils/ardrive_utils.dart';
import 'package:arweave/arweave.dart';
import 'package:flutter/foundation.dart';
import 'package:uuid/uuid.dart';

class TurboStreamedUpload implements StreamedUpload<UploadTask, dynamic> {
Expand Down Expand Up @@ -55,15 +54,6 @@ class TurboStreamedUpload implements StreamedUpload<UploadTask, dynamic> {
return;
}

/// If the file is larger than 500 MiB, we don't get progress updates.
///
/// The TurboUploadServiceImpl for web uses fetch_client for the upload of files
/// larger than 500 MiB. fetch_client does not support progress updates.
if (kIsWeb && uploadTask.uploadItem!.size > MiB(500).size) {
uploadTask = uploadTask.copyWith(
isProgressAvailable: false, status: UploadStatus.inProgress);
}

controller.updateProgress(task: uploadTask);

// gets the streamed request
Expand Down
64 changes: 26 additions & 38 deletions packages/ardrive_uploader/lib/src/turbo_upload_service_web.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import 'dart:async';
import 'dart:convert';
import 'dart:typed_data';

import 'package:ardrive_uploader/src/turbo_upload_service_base.dart';
import 'package:ardrive_utils/ardrive_utils.dart';
import 'package:arweave/arweave.dart';
import 'package:dio/dio.dart';
import 'package:fetch_client/fetch_client.dart';
import 'package:flutter/foundation.dart';
import 'package:http/http.dart' as http;

class TurboUploadServiceImpl implements TurboUploadService {
Expand All @@ -21,12 +21,14 @@ class TurboUploadServiceImpl implements TurboUploadService {
});

final _fetchController = StreamController<List<int>>(sync: false);

CancelToken _cancelToken = CancelToken();

final client = FetchClient(
mode: RequestMode.cors,
streamRequests: true,
cache: RequestCache.noCache,
handleBackPressure: true,
);

@override
Expand Down Expand Up @@ -80,12 +82,11 @@ class TurboUploadServiceImpl implements TurboUploadService {
onSendProgress: (sent, total) {
onSendProgress?.call(sent / total);
},
data: controller.stream, // Creates a Stream<List<int>>.
data: controller.stream,
options: Options(
headers: {
// stream
Headers.contentTypeHeader: 'application/octet-stream',
Headers.contentLengthHeader: size, // Set the content-length.
Headers.contentLengthHeader: size,
}..addAll(headers),
),
cancelToken: _cancelToken,
Expand Down Expand Up @@ -115,20 +116,7 @@ class TurboUploadServiceImpl implements TurboUploadService {
final url = '$turboUploadUri/v1/tx';

int dataItemSize = 0;

StreamTransformer<Uint8List, Uint8List> createPassthroughTransformer() {
return StreamTransformer.fromHandlers(
handleData: (Uint8List data, EventSink<Uint8List> sink) {
sink.add(data);
},
handleError: (Object error, StackTrace stackTrace, EventSink sink) {
sink.addError(error, stackTrace);
},
handleDone: (EventSink sink) {
sink.close();
},
);
}
int bytesUploaded = 0;

final request = ArDriveStreamedRequest(
'POST',
Expand All @@ -138,40 +126,40 @@ class TurboUploadServiceImpl implements TurboUploadService {
'content-type': 'application/octet-stream',
});

// pass through transformer so we can track progress
final transformer = StreamTransformer<Uint8List, Uint8List>.fromHandlers(
handleData: (data, sink) {
bytesUploaded += data.length;
onSendProgress?.call(bytesUploaded / size);
sink.add(data);
},
);

_fetchController
.addStream(
dataItem.streamGenerator().transform(
createPassthroughTransformer(),
),
)
.addStream(dataItem.streamGenerator().transform(transformer))
.then((value) {
print('Done');
debugPrint('stream added to fetch controller and closed');
request.sink.close();
});

_fetchController.onPause = () {
print('Paused');
debugPrint('fetch stream is paused');
};

_fetchController.onResume = () {
print('Resumed');
debugPrint('fetch stream is resumed');
};

try {
request.contentLength = dataItemSize;
request.persistentConnection = false;
request.contentLength = dataItemSize;
request.persistentConnection = false;

print('is persistent connection?${request.persistentConnection}');
debugPrint('is persistent connection?${request.persistentConnection}');

final response = await client.send(request);
final response = await client.send(request);

print(await utf8.decodeStream(response.stream));
debugPrint(await utf8.decodeStream(response.stream));

return response;
} catch (e) {
print('Error on turbo upload using FetchClient: $e');
rethrow;
}
return response;
}

@override
Expand All @@ -180,7 +168,7 @@ class TurboUploadServiceImpl implements TurboUploadService {
client.close();
_fetchController.close();
_isCanceled = true;
print('Stream closed');
debugPrint('The network request has been canceled.');
}

bool _isCanceled = false;
Expand Down
6 changes: 6 additions & 0 deletions packages/ardrive_uploader/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,9 @@ dev_dependencies:
test: ^1.21.0
json_serializable:
build_runner: ^2.0.4

dependency_overrides:
fetch_client:
git:
url: https://github.com/ardriveapp/fetch_client.git
ref: master
10 changes: 5 additions & 5 deletions packages/pst/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ packages:
path: "."
ref: "v1.3.1"
resolved-ref: "355a6113774a926e4d5df8ee9e63d8434623c7e9"
url: "https://github.com/ar-io/ardrive_http.git"
url: "https://github.com/ardriveapp/ardrive_http.git"
source: git
version: "1.3.0"
ardrive_utils:
Expand All @@ -45,11 +45,11 @@ packages:
dependency: "direct main"
description:
path: "."
ref: "v3.8.1"
resolved-ref: "6629b72b6e36a1628fd5a74a5deb5cae24d09fe5"
ref: "v3.8.2"
resolved-ref: "363d4b69be03d2e67390e7c70eb7c3a230377001"
url: "https://github.com/ardriveapp/arweave-dart.git"
source: git
version: "3.8.1"
version: "3.8.2"
async:
dependency: transitive
description:
Expand Down Expand Up @@ -240,7 +240,7 @@ packages:
path: "."
ref: PE-4754-address-code-review-comments-on-uploader-downloader-implementations
resolved-ref: "95241dd94f0f64bae7553e7a3bbaa5d0558f63ee"
url: "https://github.com/thiagocarvalhodev/fetch_client.git"
url: "https://github.com/ardriveapp/fetch_client.git"
source: git
version: "1.0.2"
ffi:
Expand Down
21 changes: 11 additions & 10 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -561,19 +561,20 @@ packages:
source: hosted
version: "1.3.1"
fetch_api:
dependency: transitive
dependency: "direct overridden"
description:
name: fetch_api
sha256: "7896632eda5af40c4459d673ad601df21d4c3ae6a45997e300a92ca63ec9fe4c"
url: "https://pub.dev"
source: hosted
version: "1.0.1"
path: "."
ref: master
resolved-ref: ef5e490d063644d0e875a5402bcd9236e37bd2b1
url: "https://github.com/ardriveapp/fetch_api.git"
source: git
version: "1.0.3"
fetch_client:
dependency: transitive
dependency: "direct overridden"
description:
path: "."
ref: PE-4754-address-code-review-comments-on-uploader-downloader-implementations
resolved-ref: "95241dd94f0f64bae7553e7a3bbaa5d0558f63ee"
ref: master
resolved-ref: bb61a9c832f04a3939f1f7f4850f137bf4ee679b
url: "https://github.com/ardriveapp/fetch_client.git"
source: git
version: "1.0.2"
Expand Down Expand Up @@ -771,7 +772,7 @@ packages:
path: flutter_dropzone
ref: master
resolved-ref: cf486176da4efa1367130efc902fa5935a069968
url: "https://github.com/ar-io/flutter_dropzone"
url: "https://github.com/ardriveapp/flutter_dropzone"
source: git
version: "3.0.5"
flutter_dropzone_platform_interface:
Expand Down
12 changes: 10 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Secure, permanent storage

publish_to: 'none'

version: 2.26.1
version: 2.27.0

environment:
sdk: '>=3.0.2 <4.0.0'
Expand Down Expand Up @@ -70,7 +70,7 @@ dependencies:
uuid: ^3.0.4
flutter_dropzone:
git:
url: https://github.com/ar-io/flutter_dropzone
url: https://github.com/ardriveapp/flutter_dropzone
ref: master
path: flutter_dropzone
responsive_builder: ^0.7.0
Expand Down Expand Up @@ -141,6 +141,14 @@ dependency_overrides:
url: https://github.com/ardriveapp/flutter_stripe/
path: packages/stripe_platform_interface
ref: main
fetch_client:
git:
url: https://github.com/ardriveapp/fetch_client.git
ref: master
fetch_api:
git:
url: https://github.com/ardriveapp/fetch_api.git
ref: master
http: ^1.1.0

dev_dependencies:
Expand Down

0 comments on commit 158d137

Please sign in to comment.