-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1559 from ardriveapp/PE-5397
PE-5387: chunk uploads to turbo
- Loading branch information
Showing
27 changed files
with
611 additions
and
630 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,14 @@ | ||
import 'package:ardrive_utils/ardrive_utils.dart'; | ||
|
||
final privateFileSizeLimit = const GiB(65).size; | ||
final fileSizeLimit = const GiB(65).size; | ||
final fileSizeWarning = const GiB(5).size; | ||
|
||
final largeFileUploadSizeThreshold = const MiB(500).size; | ||
|
||
final mobilePrivateFileSizeLimit = const GiB(10).size; | ||
const maxBundleDataItemCount = 500; | ||
const maxFilesPerBundle = maxBundleDataItemCount ~/ 2; | ||
const maxFilesSizePerBundleUsingTurbo = 1; | ||
|
||
final publicFileSafeSizeLimit = const GiB(5).size; | ||
final nonChromeBrowserUploadSafeLimitUsingTurbo = const MiB(500).size; | ||
final d2nBundleSizeLimit = const GiB(65).size; | ||
final turboBundleSizeLimit = const GiB(10).size; | ||
|
||
int getBundleSizeLimit(bool isTurbo) => | ||
isTurbo ? turboBundleSizeLimit : d2nBundleSizeLimit; | ||
|
||
final d2nBundleSizeLimit = const GiB(65).size; | ||
final turboBundleSizeLimit = const GiB(10).size; | ||
final mobileBundleSizeLimit = const GiB(65).size; | ||
const maxBundleDataItemCount = 500; | ||
const maxFilesPerBundle = maxBundleDataItemCount ~/ 2; | ||
const maxFilesSizePerBundleUsingTurbo = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,51 @@ | ||
import 'package:ardrive/blocs/upload/models/upload_file.dart'; | ||
|
||
class UploadFileChecker { | ||
UploadFileChecker({ | ||
required int publicFileSafeSizeLimit, | ||
required int privateFileSafeSizeLimit, | ||
}) : _publicFileSafeSizeLimit = publicFileSafeSizeLimit, | ||
_privateFileSafeSizeLimit = privateFileSafeSizeLimit; | ||
|
||
final int _publicFileSafeSizeLimit; | ||
final int _privateFileSafeSizeLimit; | ||
|
||
Future<bool> hasFileAboveSafePublicSizeLimit( | ||
{required List<UploadFile> files}) async { | ||
class UploadFileSizeChecker { | ||
UploadFileSizeChecker({ | ||
required int fileSizeLimit, | ||
required int fileSizeWarning, | ||
}) : _fileSizeLimit = fileSizeLimit, | ||
_fileSizeWarning = fileSizeWarning; | ||
|
||
final int _fileSizeLimit; | ||
final int _fileSizeWarning; | ||
|
||
Future<bool> hasFileAboveSizeLimit({ | ||
required List<UploadFile> files, | ||
}) => | ||
_hasFileAboveLimit(files: files, limit: _fileSizeLimit); | ||
|
||
Future<bool> hasFileAboveWarningSizeLimit({ | ||
required List<UploadFile> files, | ||
}) => | ||
_hasFileAboveLimit(files: files, limit: _fileSizeWarning); | ||
|
||
Future<List<String>> getFilesAboveSizeLimit({ | ||
required List<UploadFile> files, | ||
}) async { | ||
final filesAboveSizeLimit = <String>[]; | ||
|
||
for (final file in files) { | ||
final fileSize = await file.ioFile.length; | ||
if (fileSize > _publicFileSafeSizeLimit) { | ||
return true; | ||
if (fileSize > _fileSizeLimit) { | ||
filesAboveSizeLimit.add(file.getIdentifier()); | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
Future<List<String>> checkAndReturnFilesAbovePrivateLimit( | ||
{required List<UploadFile> files}) async { | ||
final filesAbovePrivateLimit = <String>[]; | ||
return filesAboveSizeLimit; | ||
} | ||
|
||
Future<bool> _hasFileAboveLimit({ | ||
required List<UploadFile> files, | ||
required int limit, | ||
}) async { | ||
for (final file in files) { | ||
final fileSize = await file.ioFile.length; | ||
if (fileSize > _privateFileSafeSizeLimit) { | ||
filesAbovePrivateLimit.add(file.getIdentifier()); | ||
if (fileSize > limit) { | ||
return true; | ||
} | ||
} | ||
|
||
return filesAbovePrivateLimit; | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.