Files
PeachDeployments/lib/Peach/about/internal/file/FileStorage.dart
alvocool 38881d1fe1 Add app source and tests
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-11 10:15:30 +03:00

48 lines
1.4 KiB
Dart

import 'dart:io';
import 'package:flutter/foundation.dart';
import '../../../comms/Comms.dart' show LogLine;
import '../application/ServiceConfig.dart';
import '../application/StepTracker.dart';
import 'BuildService.dart';
import 'ConnectFileStorage.dart';
import 'WebArchive.dart';
/// The one concrete [ConnectFileStorage]. Owns the [BuildService] and delegates
/// archiving to [WebArchive]; holds no state of its own beyond the builder.
class FileStorage implements ConnectFileStorage {
final BuildService _builder = BuildService();
@override
bool get buildSupported => BuildService.supported;
@override
Stream<LogLine> get buildLogs => _builder.logs;
@override
Stream<List<DeployStep>> get buildStepStream => _builder.stepStream;
@override
Future<BuildResult> build(ServiceConfig service) => _builder.build(service);
@override
Future<BuildResult> buildWeb(ServiceConfig service) =>
_builder.buildWeb(service);
@override
void cancelBuild() => _builder.cancel();
@override
Future<Uint8List> readArtifact(String path) => File(path).readAsBytes();
@override
Future<bool> artifactExists(String path) => File(path).exists();
@override
Future<(Uint8List, int)> packageWeb(String directoryPath) =>
// Packaging a large static tree blocks long enough to drop frames, so it
// runs on a background isolate.
compute(packageWebDir, directoryPath);
}