From fa1611f96ba4e56f4d8cc362a192bdd29351f51f Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 30 May 2021 20:22:56 +0200 Subject: fix readlink in download_async_gui --- src/DownloadUtils.cpp | 11 ++++++----- src/QuickMedia.cpp | 4 +--- 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/DownloadUtils.cpp b/src/DownloadUtils.cpp index 9834390..774fba9 100644 --- a/src/DownloadUtils.cpp +++ b/src/DownloadUtils.cpp @@ -214,11 +214,12 @@ namespace QuickMedia { } bool download_async_gui(const std::string &url, const std::string &file_manager_start_dir, bool use_youtube_dl, bool no_video) { - // TODO: Fix this not working when installed to /usr/bin/quickmedia for some reason - //char quickmedia_path[PATH_MAX]; - //if(readlink("/proc/self/exe", quickmedia_path, sizeof(quickmedia_path)) == -1) - // strcpy(quickmedia_path, "quickmedia"); - const char *quickmedia_path = "quickmedia"; + char quickmedia_path[PATH_MAX]; + ssize_t bytes_written = readlink("/proc/self/exe", quickmedia_path, sizeof(quickmedia_path)); + if(bytes_written == -1 || bytes_written == sizeof(quickmedia_path)) + strcpy(quickmedia_path, "quickmedia"); + else + quickmedia_path[bytes_written] = '\0'; std::vector args = { quickmedia_path, "download", "-u", url.c_str(), "--dir", file_manager_start_dir.c_str() }; if(use_youtube_dl) args.push_back("--youtube-dl"); diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 595ae7b..5bbad84 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -1889,9 +1889,7 @@ namespace QuickMedia { BodyItem *selected_item = tabs[selected_tab].body->get_selected(); if(selected_item && tabs[selected_tab].page->is_trackable()) { TrackablePage *trackable_page = dynamic_cast(tabs[selected_tab].page.get()); - run_task_with_loading_screen([trackable_page, selected_item](){ - return trackable_page->track(selected_item->get_title()) == TrackResult::OK; - }); + trackable_page->track(selected_item->get_title()); } } else if(event.key.code == sf::Keyboard::C && event.key.control) { BodyItem *selected_item = tabs[selected_tab].body->get_selected(); -- cgit v1.2.3