aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-09-08 22:58:14 +0200
committerdec05eba <dec05eba@protonmail.com>2022-09-08 22:58:14 +0200
commitb677cfe8c261bae436d3e70a45256d79cfda28e3 (patch)
tree48373423144b837827b0123be54eb13deed5c503
parentd0dda48e791e6f08f6be3936623a2c305caacb3c (diff)
Remove linux specific sendfile function (unused)
-rw-r--r--TODO3
-rw-r--r--include/AsyncImageLoader.hpp2
-rw-r--r--src/AsyncImageLoader.cpp37
-rw-r--r--src/plugins/Matrix.cpp2
4 files changed, 7 insertions, 37 deletions
diff --git a/TODO b/TODO
index ef5e678..36314ea 100644
--- a/TODO
+++ b/TODO
@@ -232,4 +232,5 @@ Instead of having an option to disable rounded corners, add an option to set cor
Support proper emoji, maybe a different emoji per image.
Consider adding an option to use external sxiv, imv etc instead of mpv/quickmedia image viewer.
Fallback to playing videos/etc from origin homeserver in matrix if the file is larger than the users homeserver allows. This wont work with pantalaimon + encrypted rooms, so it should be delayed until quickmedia supports matrix encryption.
-Fix 4chan posting! cloudflare broke shit. Then create external captcha solver program that solves captcha from captcha image. \ No newline at end of file
+Fix 4chan posting! cloudflare broke shit. Then create external captcha solver program that solves captcha from captcha image.
+Add option to use invidious, and the invidious front page. \ No newline at end of file
diff --git a/include/AsyncImageLoader.hpp b/include/AsyncImageLoader.hpp
index c482a3a..986430c 100644
--- a/include/AsyncImageLoader.hpp
+++ b/include/AsyncImageLoader.hpp
@@ -39,7 +39,7 @@ namespace QuickMedia {
// If |symlink_if_no_resize| is false then a copy is made from |thumbnail_path| to |thumbnail_path_resized| instead of a symlink if |thumbnail_path| is not larger than |resize_target_size|.
// One example of why you might not want a symlink is if |thumbnail_path| is a temporary file.
- bool create_thumbnail(const Path &thumbnail_path, const Path &thumbnail_path_resized, mgl::vec2i resize_target_size, ContentType content_type, bool symlink_if_no_resize);
+ bool create_thumbnail(const Path &thumbnail_path, const Path &thumbnail_path_resized, mgl::vec2i resize_target_size, ContentType content_type);
constexpr int NUM_IMAGE_DOWNLOAD_PARALLEL = 4;
constexpr int NUM_IMAGE_LOAD_PARALLEL = 4;
diff --git a/src/AsyncImageLoader.cpp b/src/AsyncImageLoader.cpp
index 883073f..09c01df 100644
--- a/src/AsyncImageLoader.cpp
+++ b/src/AsyncImageLoader.cpp
@@ -10,7 +10,6 @@
#include <sys/prctl.h>
#include <sys/stat.h>
#include <sys/wait.h>
-#include <sys/sendfile.h>
#include <sys/time.h>
#include <fcntl.h>
#include <signal.h>
@@ -32,7 +31,7 @@ namespace QuickMedia {
return exec_program(args, nullptr, nullptr) == 0;
}
- bool create_thumbnail(const Path &thumbnail_path, const Path &thumbnail_path_resized, mgl::vec2i resize_target_size, ContentType content_type, bool symlink_if_no_resize) {
+ bool create_thumbnail(const Path &thumbnail_path, const Path &thumbnail_path_resized, mgl::vec2i resize_target_size, ContentType content_type) {
Path input_path = thumbnail_path;
if(content_type == ContentType::IMAGE_WEBP) {
@@ -75,42 +74,12 @@ namespace QuickMedia {
_exit(0);
else
_exit(1);
- } else if(symlink_if_no_resize) {
+ } else {
int res = symlink(thumbnail_path.data.c_str(), result_path_tmp.data.c_str());
if(res == -1 && errno != EEXIST) {
fprintf(stderr, "Failed to symlink %s to %s\n", result_path_tmp.data.c_str(), thumbnail_path.data.c_str());
_exit(1);
}
- } else {
- // TODO: When mac is supported (or other OS than linux), then fix this for them. Mac for example needs fcopyfile instead of sendfile
- int input_file = open(thumbnail_path.data.c_str(), O_RDONLY);
- if(input_file == -1) {
- fprintf(stderr, "Failed to save %s\n", thumbnail_path_resized.data.c_str());
- _exit(1);
- }
-
- int output_file = creat(result_path_tmp.data.c_str(), 0660);
- if(output_file == -1) {
- fprintf(stderr, "Failed to save %s\n", thumbnail_path_resized.data.c_str());
- _exit(1);
- }
-
- off_t bytes_copied = 0;
- struct stat file_stat;
- memset(&file_stat, 0, sizeof(file_stat));
- if(fstat(input_file, &file_stat) == -1) {
- fprintf(stderr, "Failed to save %s\n", thumbnail_path_resized.data.c_str());
- _exit(1);
- }
-
- // No need to retry, small files
- if(sendfile(output_file, input_file, &bytes_copied, file_stat.st_size) == -1) {
- fprintf(stderr, "Failed to save %s\n", thumbnail_path_resized.data.c_str());
- _exit(1);
- }
-
- close(input_file);
- close(output_file);
}
} else {
mgl::vec2i clamped_size = clamp_to_size(image.get_size(), mgl::vec2i(resize_target_size.x, resize_target_size.y));
@@ -178,7 +147,7 @@ namespace QuickMedia {
return;
}
- if(create_thumbnail(thumbnail_path, thumbnail_path_resized, resize_target_size, file_analyzer.get_content_type(), true)) {
+ if(create_thumbnail(thumbnail_path, thumbnail_path_resized, resize_target_size, file_analyzer.get_content_type())) {
thumbnail_data->loading_state = LoadingState::READY_TO_LOAD;
} else {
fprintf(stderr, "Failed to convert %s to a thumbnail\n", thumbnail_path.data.c_str());
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp
index b54092e..f8ee2a2 100644
--- a/src/plugins/Matrix.cpp
+++ b/src/plugins/Matrix.cpp
@@ -3742,7 +3742,7 @@ namespace QuickMedia {
int tmp_file = mkstemp(tmp_filename);
if(tmp_file != -1) {
std::string thumbnail_path;
- if(create_thumbnail(filepath, tmp_filename, thumbnail_max_size, file_analyzer.get_content_type(), true))
+ if(create_thumbnail(filepath, tmp_filename, thumbnail_max_size, file_analyzer.get_content_type()))
thumbnail_path = tmp_filename;
else
thumbnail_path = filepath;