aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/AsyncImageLoader.cpp37
-rw-r--r--src/plugins/Matrix.cpp2
2 files changed, 4 insertions, 35 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());
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;