FINALLY FIXED AUTO UPDATE
This commit is contained in:
parent
8feea02f68
commit
fceb4e050f
filcnaplo/lib/helpers
@ -9,7 +9,7 @@ import 'package:permission_handler/permission_handler.dart';
|
||||
class StorageHelper {
|
||||
static Future<bool> write(String path, Uint8List data) async {
|
||||
try {
|
||||
if (await Permission.storage.request().isGranted) {
|
||||
if (await Permission.manageExternalStorage.request().isGranted) {
|
||||
await File(path).writeAsBytes(data);
|
||||
return true;
|
||||
} else {
|
||||
@ -34,5 +34,6 @@ class StorageHelper {
|
||||
}
|
||||
|
||||
return downloads;
|
||||
// return (await getTemporaryDirectory()).path;
|
||||
}
|
||||
}
|
||||
|
@ -25,14 +25,9 @@ extension UpdateHelper on Release {
|
||||
if (!await apk.exists()) {
|
||||
updateCallback(-1, UpdateState.downloading);
|
||||
|
||||
var storagePerms = await Permission.storage.request().isGranted;
|
||||
if (storagePerms) {
|
||||
var bytes = await download(updateCallback: updateCallback);
|
||||
if (!await StorageHelper.write(apk.path, bytes)) {
|
||||
throw "failed to write apk: permission denied";
|
||||
}
|
||||
} else {
|
||||
throw storagePerms;
|
||||
var bytes = await download(updateCallback: updateCallback);
|
||||
if (!await StorageHelper.write(apk.path, bytes)) {
|
||||
throw "failed to write apk: permission denied";
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user