aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-09-10 13:31:24 +0200
committerdec05eba <dec05eba@protonmail.com>2021-09-10 14:07:31 +0200
commit6eb8d7fbcbc64bcb89083ab46d591d9f9ed5b388 (patch)
treeacfd12e231bc1a8fd9905b4035cf58d089f88343 /src
parentb88c367c48da452f0100bd8cffaba5d76cd83f0d (diff)
Convert file-manager --dir to absolute path
Fixes parent navigation when using relative path for --dir. Submit should not be async for peertube. Fixes peertube video length.
Diffstat (limited to 'src')
-rw-r--r--src/DownloadUtils.cpp4
-rw-r--r--src/QuickMedia.cpp16
-rw-r--r--src/plugins/Peertube.cpp1
3 files changed, 18 insertions, 3 deletions
diff --git a/src/DownloadUtils.cpp b/src/DownloadUtils.cpp
index 93df291..6df9c74 100644
--- a/src/DownloadUtils.cpp
+++ b/src/DownloadUtils.cpp
@@ -293,8 +293,8 @@ namespace QuickMedia {
bool download_async_gui(const std::string &url, const std::string &file_manager_start_dir, bool no_video) {
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))
+ ssize_t bytes_written = readlink("/proc/self/exe", quickmedia_path, sizeof(quickmedia_path) - 1);
+ if(bytes_written == -1)
strcpy(quickmedia_path, "quickmedia");
else
quickmedia_path[bytes_written] = '\0';
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 32696b6..aef1073 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -46,6 +46,7 @@
#include <malloc.h>
#include <unistd.h>
#include <libgen.h>
+#include <limits.h>
#include <SFML/Graphics/RectangleShape.hpp>
#include <SFML/Window/Clipboard.hpp>
@@ -314,6 +315,15 @@ namespace QuickMedia {
return body_item;
}
+ static bool convert_to_absolute_path(std::filesystem::path &path) {
+ char resolved[PATH_MAX];
+ if(!realpath(path.c_str(), resolved))
+ return false;
+
+ path = resolved;
+ return true;
+ }
+
int Program::run(int argc, char **argv) {
if(argc < 1) {
usage();
@@ -456,8 +466,12 @@ namespace QuickMedia {
}
std::filesystem::path home_path = get_home_dir().data;
- if(file_manager_start_dir.empty())
+ if(file_manager_start_dir.empty()) {
file_manager_start_dir = home_path;
+ } else {
+ if(!convert_to_absolute_path(file_manager_start_dir))
+ fprintf(stderr, "Warning: failed to get absolute path for path: %s\n", file_manager_start_dir.c_str());
+ }
int start_tab_index = 0;
FileManagerMimeType fm_mine_type = FILE_MANAGER_MIME_TYPE_ALL;
diff --git a/src/plugins/Peertube.cpp b/src/plugins/Peertube.cpp
index df715c1..db55584 100644
--- a/src/plugins/Peertube.cpp
+++ b/src/plugins/Peertube.cpp
@@ -50,6 +50,7 @@ namespace QuickMedia {
if(hours >= 1) {
minutes -= (hours * 60);
seconds -= (hours * 60 * 60);
+ seconds -= (minutes * 60);
snprintf(buffer, sizeof(buffer), "%02d:%02d:%02d", hours, minutes, seconds);
} else if(minutes >= 1) {
seconds -= (minutes * 60);