mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-07-26 14:01:03 +02:00
feat(downloads): detect lost SAF grant and offer folder re-selection
A persisted SAF tree grant can die silently (folder deleted or renamed, SD card removed, app data reset, system revocation). Downloads then fail with no recovery path beyond digging through Settings. - Add isSafTreeAccessible bridge method: the grant must still be in the system's persisted permission list and the tree writable - Show a warning banner in Files & Folders when the saved SAF folder is no longer accessible, with an inline re-select action - In the download error dialog, replace Retry with a Re-select folder action when the failure is a lost folder grant (Android SAF or iOS bookmark); a successful re-pick retries the item automatically - Share the folder-access error messages as constants so the UI can match on them reliably
This commit is contained in:
@@ -598,6 +598,22 @@ class PlatformBridge {
|
||||
return result as bool;
|
||||
}
|
||||
|
||||
/// Whether the persisted SAF grant for [treeUri] is still usable: the
|
||||
/// permission is present in the system's persisted list and the tree
|
||||
/// document still exists and is writable. Returns true on channel errors
|
||||
/// so a bridge problem never raises a false "access lost" alarm.
|
||||
static Future<bool> isSafTreeAccessible(String treeUri) async {
|
||||
try {
|
||||
final result = await _channel.invokeMethod('isSafTreeAccessible', {
|
||||
'tree_uri': treeUri,
|
||||
});
|
||||
return result as bool? ?? true;
|
||||
} catch (e) {
|
||||
_log.w('Failed to check SAF tree accessibility: $e');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static Future<bool> safDelete(String uri) async {
|
||||
final result = await _channel.invokeMethod('safDelete', {'uri': uri});
|
||||
return result as bool;
|
||||
|
||||
Reference in New Issue
Block a user