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