Merge branch 'main' into fix/bring-back-delete-backed-up-only

This commit is contained in:
Alex
2025-10-02 11:30:47 -05:00
committed by GitHub
266 changed files with 12110 additions and 4362 deletions
@@ -89,6 +89,7 @@ class AssetMediaRepository {
// TODO: make this more efficient
Future<int> shareAssets(List<BaseAsset> assets, BuildContext context) async {
final downloadedXFiles = <XFile>[];
final tempFiles = <File>[];
for (var asset in assets) {
final localId = (asset is LocalAsset)
@@ -99,6 +100,9 @@ class AssetMediaRepository {
if (localId != null) {
File? f = await AssetEntity(id: localId, width: 1, height: 1, typeInt: 0).originFile;
downloadedXFiles.add(XFile(f!.path));
if (CurrentPlatform.isIOS) {
tempFiles.add(f);
}
} else if (asset is RemoteAsset) {
final tempDir = await getTemporaryDirectory();
final name = asset.name;
@@ -112,6 +116,7 @@ class AssetMediaRepository {
await tempFile.writeAsBytes(res.bodyBytes);
downloadedXFiles.add(XFile(tempFile.path));
tempFiles.add(tempFile);
} else {
_log.warning("Asset type not supported for sharing: $asset");
continue;
@@ -130,9 +135,9 @@ class AssetMediaRepository {
downloadedXFiles,
sharePositionOrigin: Rect.fromPoints(Offset.zero, Offset(size.width / 3, size.height)),
).then((result) async {
for (var file in downloadedXFiles) {
for (var file in tempFiles) {
try {
await File(file.path).delete();
await file.delete();
} catch (e) {
_log.warning("Failed to delete temporary file: ${file.path}", e);
}