aboutsummaryrefslogtreecommitdiff
path: root/src/AsyncImageLoader.cpp
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 /src/AsyncImageLoader.cpp
parentd0dda48e791e6f08f6be3936623a2c305caacb3c (diff)
Remove linux specific sendfile function (unused)
Diffstat (limited to 'src/AsyncImageLoader.cpp')
-rw-r--r--src/AsyncImageLoader.cpp37
1 files changed, 3 insertions, 34 deletions
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());