Fixed bug, downlaoded file play error.

This commit is contained in:
stonegate 2020-08-19 18:09:05 +08:00
parent 626763850b
commit e9e27d8cb6
2 changed files with 16 additions and 15 deletions

View File

@ -1177,12 +1177,6 @@ class DBHelper {
list.first['is_new'],
mediaId: list.first['media_id'],
skipSeconds: list.first['skip_seconds']);
if (episode.enclosureUrl != episode.mediaId &&
!File(episode.mediaId.substring(7)).existsSync()) {
final url = episode.enclosureUrl;
await delDownloaded(url);
episode = episode.copyWith(mediaId: url);
}
return episode;
}
}
@ -1211,12 +1205,6 @@ class DBHelper {
list.first['is_new'],
mediaId: list.first['media_id'],
skipSeconds: list.first['skip_seconds']);
if (episode.enclosureUrl != episode.mediaId &&
!File(episode.mediaId.substring(7)).existsSync()) {
final url = episode.enclosureUrl;
await delDownloaded(url);
episode = episode.copyWith(mediaId: url);
}
return episode;
}
}

View File

@ -151,7 +151,7 @@ class DownloadState extends ChangeNotifier {
super.addListener(listener);
}
_loadTasks() async {
Future<void> _loadTasks() async {
_episodeTasks = [];
var dbHelper = DBHelper();
var tasks = await FlutterDownloader.loadTasks();
@ -162,8 +162,21 @@ class DownloadState extends ChangeNotifier {
await FlutterDownloader.remove(
taskId: task.taskId, shouldDeleteContent: true);
} else {
_episodeTasks.add(EpisodeTask(episode, task.taskId,
progress: task.progress, status: task.status));
if (task.status == DownloadTaskStatus.complete) {
var exist =
await File(path.join(task.savedDir, task.filename)).exists();
if (!exist) {
await FlutterDownloader.remove(
taskId: task.taskId, shouldDeleteContent: true);
await dbHelper.delDownloaded(episode.enclosureUrl);
} else {
_episodeTasks.add(EpisodeTask(episode, task.taskId,
progress: task.progress, status: task.status));
}
} else {
_episodeTasks.add(EpisodeTask(episode, task.taskId,
progress: task.progress, status: task.status));
}
}
}
}