Skip to content

Commit

Permalink
fix: fallback for faulty sd card path
Browse files Browse the repository at this point in the history
ref #199
  • Loading branch information
MSOB7YY committed May 18, 2024
1 parent 67f11e5 commit 0b00181
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions lib/controller/file_browser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ class _NamidaFileBrowserBase<T extends FileSystemEntity> extends StatefulWidget
),
);
final all = await completer.future;
return all.firstOrNull;
if (all.isEmpty) return null;
return _fixSDCardDirectory(all[0]);
}

static Future<List<Directory>> pickDirectories({
Expand All @@ -199,7 +200,14 @@ class _NamidaFileBrowserBase<T extends FileSystemEntity> extends StatefulWidget
allowMultiple: true,
),
);
return completer.future;
final res = await completer.future;
return res.map((e) => _fixSDCardDirectory(e)).toList();
}

static final _sdDirRegex = RegExp(r'/tree/(\w{4}-\w{4}):');
static Directory _fixSDCardDirectory(Directory dir) {
final replaced = dir.path.replaceFirstMapped(_sdDirRegex, (match) => '/storage/${match.group(1)}/');
return Directory(replaced);
}

@override
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: namida
description: A Beautiful and Feature-rich Music Player, With YouTube & Video Support Built in Flutter
publish_to: "none"
version: 2.4.43-beta+240518207
version: 2.4.44-beta+240518208

environment:
sdk: ">=3.1.4 <4.0.0"
Expand Down

0 comments on commit 0b00181

Please sign in to comment.