From c1d0fe75d267f33724c38af95efc7b1c050dc160 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 17 Jun 2021 08:54:00 +0200 Subject: Temporary abort on fail to read file.. if its being modified while reading --- src/QuickMedia.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/QuickMedia.cpp') diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 82741bb..77098a3 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -1360,8 +1360,15 @@ namespace QuickMedia { Json::Value Program::load_video_history_json() { Path video_history_filepath = get_video_history_filepath(plugin_name); Json::Value json_result; - if(!read_file_as_json(video_history_filepath, json_result) || !json_result.isArray()) + FileType file_type = get_file_type(video_history_filepath); + if(file_type == FileType::REGULAR) { + if(!read_file_as_json(video_history_filepath, json_result) || !json_result.isArray()) { + show_notification("QuickMedia", "Failed to read " + video_history_filepath.data, Urgency::CRITICAL); + abort(); + } + } else { json_result = Json::Value(Json::arrayValue); + } return json_result; } @@ -1473,6 +1480,10 @@ namespace QuickMedia { FileType file_type = get_file_type(content_storage_file); if(file_type == FileType::REGULAR) { result = read_file_as_json(content_storage_file, content_storage_json) && content_storage_json.isObject(); + if(!result) { + show_notification("QuickMedia", "Failed to read " + content_storage_file.data, Urgency::CRITICAL); + abort(); + } } else { result = true; } @@ -2916,9 +2927,9 @@ namespace QuickMedia { load_video_error_check(); } else if(update_err != VideoPlayer::Error::OK) { + ++load_try; if(load_try < num_load_tries_max) { fprintf(stderr, "Failed to play the media, retrying (try %d out of %d)\n", 1 + load_try, num_load_tries_max); - ++load_try; load_video_error_check(prev_start_time); } else { show_notification("QuickMedia", "Failed to play the video (error code " + std::to_string((int)update_err) + ")", Urgency::CRITICAL); -- cgit v1.2.3