Skip to content

Commit

Permalink
fix: memory issue on extracting
Browse files Browse the repository at this point in the history
  • Loading branch information
Sivan22 committed Nov 11, 2024
1 parent 52d7c7f commit b373e1b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 24 deletions.
21 changes: 17 additions & 4 deletions .github/workflows/flutter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,22 @@ jobs:
channel: stable
cache: true
- run: flutter pub get
- run: flutter build ios --release --no-codesign
- name: Upload iphone build
- name: Build iOS
run: |
flutter build ios --release
cd build/ios/iphoneos
mkdir Payload
cp -r Runner.app Payload
zip -r otzaria-ios.ipa Payload
- name: Upload iOS build
uses: actions/upload-artifact@v4
with:
name: otzaria-iphone.app
path: build/ios/iphoneos/Runner.app
name: otzaria-ios.ipa
path: build/ios/iphoneos/otzaria-ios.ipa
- name: Upload iOS archive
uses: actions/upload-artifact@v4
with:
name: ios-build
path: |
build/ios/archive/Runner.xcarchive
build/ios/iphoneos/
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
buildscript {
ext.kotlin_version = '1.9.22'
ext.kotlin_version = "2.1.0-RC"
repositories {
google()
mavenCentral()
Expand Down
22 changes: 3 additions & 19 deletions lib/screens/empty_library_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -201,25 +201,9 @@ class _EmptyLibraryScreenState extends State<EmptyLibraryScreen> {
if (file.isFile) {
final outputFile = File(filePath);
await outputFile.parent.create(recursive: true);

// Use streaming to write file contents
if (file.content != null) {
final sink = outputFile.openWrite();
try {
// Process in chunks to avoid memory issues
const chunkSize = 1024 * 1024; // 1MB chunks
final content = file.content as List<int>;
for (var i = 0; i < content.length; i += chunkSize) {
final end = (i + chunkSize < content.length)
? i + chunkSize
: content.length;
sink.add(content.sublist(i, end));
await sink.flush();
}
} finally {
await sink.close();
}
}
final outputStream = OutputFileStream(outputFile.path);
file.writeContent(outputStream);
outputStream.close();
} else {
await Directory(filePath).create(recursive: true);
}
Expand Down

0 comments on commit b373e1b

Please sign in to comment.