Skip to content

Commit

Permalink
fix: The presence of a lost+found folder makes musicpod unable to loa…
Browse files Browse the repository at this point in the history
…d the users music library (#935)

Ref #934
  • Loading branch information
Feichtmeier authored Oct 1, 2024
1 parent 8c3bb05 commit 66bca61
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions lib/local_audio/local_audio_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -252,15 +252,18 @@ FutureOr<ImportResult> _readAudiosFromDirectory(String? directory) async {
List<String> failedImports = [];

if (directory != null && Directory(directory).existsSync()) {
for (var e in Directory(directory)
.listSync(recursive: true, followLinks: false)
.whereType<File>()
.where((e) => e.isValidMedia)
.toList()) {
final entities = await Directory(directory)
.list(recursive: true, followLinks: false)
.handleError((e) => failedImports.add(e))
.toList();

for (final e in entities) {
try {
final metadata = await readMetadata(e, getImage: false);
newAudios.add(Audio.fromMetadata(path: e.path, data: metadata));
} catch (error) {
if (e is File && e.isValidMedia) {
final metadata = await readMetadata(e, getImage: false);
newAudios.add(Audio.fromMetadata(path: e.path, data: metadata));
}
} on Exception catch (_) {
failedImports.add(e.path);
}
}
Expand Down

0 comments on commit 66bca61

Please sign in to comment.