aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-09-12 01:08:31 +0200
committerdec05eba <dec05eba@protonmail.com>2022-09-12 01:08:31 +0200
commitc944b7b874ce2296b0c67cd9e7c670304c514e1f (patch)
tree1a13a4381f2bd3126cbd8a1b4161ad2d962b9d23 /src/plugins
parentef4442c6f58929f2eefb10be218b8d3638d88358 (diff)
Sneed moment
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/FileManager.cpp2
-rw-r--r--src/plugins/Matrix.cpp12
2 files changed, 9 insertions, 5 deletions
diff --git a/src/plugins/FileManager.cpp b/src/plugins/FileManager.cpp
index 5fd6670..45c61bf 100644
--- a/src/plugins/FileManager.cpp
+++ b/src/plugins/FileManager.cpp
@@ -21,6 +21,8 @@ namespace QuickMedia {
const char *path_c = path.c_str();
int len = strlen(path_c);
for(int i = len - 1; i >= 0; --i) {
+ if(path_c[i] == '/')
+ return "";
if(path_c[i] == '.')
return path_c + i;
}
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp
index 00009fd..14f49bf 100644
--- a/src/plugins/Matrix.cpp
+++ b/src/plugins/Matrix.cpp
@@ -3674,7 +3674,7 @@ namespace QuickMedia {
PluginResult Matrix::post_file(RoomData *room, const std::string &filepath, std::string filename, std::string &event_id_response, std::string &err_msg) {
UploadInfo file_info;
UploadInfo thumbnail_info;
- PluginResult upload_file_result = upload_file(room, filepath, file_info, thumbnail_info, err_msg);
+ PluginResult upload_file_result = upload_file(room, filepath, filename, file_info, thumbnail_info, err_msg);
if(upload_file_result != PluginResult::OK)
return upload_file_result;
@@ -3689,7 +3689,7 @@ namespace QuickMedia {
return post_message(room, filename, event_id_response, file_info_opt, thumbnail_info_opt);
}
- PluginResult Matrix::upload_file(RoomData *room, const std::string &filepath, UploadInfo &file_info, UploadInfo &thumbnail_info, std::string &err_msg, bool upload_thumbnail) {
+ PluginResult Matrix::upload_file(RoomData *room, const std::string &filepath, std::string filename, UploadInfo &file_info, UploadInfo &thumbnail_info, std::string &err_msg, bool upload_thumbnail) {
FileAnalyzer file_analyzer;
if(!file_analyzer.load_file(filepath.c_str(), true)) {
err_msg = "Failed to load " + filepath;
@@ -3725,7 +3725,7 @@ namespace QuickMedia {
if(tmp_file != -1) {
if(video_get_first_frame(file_analyzer, tmp_filename, thumbnail_max_size.x, thumbnail_max_size.y)) {
UploadInfo upload_info_ignored; // Ignore because it wont be set anyways. Thumbnails dont have thumbnails.
- PluginResult upload_thumbnail_result = upload_file(room, tmp_filename, thumbnail_info, upload_info_ignored, err_msg, false);
+ PluginResult upload_thumbnail_result = upload_file(room, tmp_filename, "", thumbnail_info, upload_info_ignored, err_msg, false);
if(upload_thumbnail_result != PluginResult::OK) {
close(tmp_file);
remove(tmp_filename);
@@ -3750,7 +3750,7 @@ namespace QuickMedia {
thumbnail_path = filepath;
UploadInfo upload_info_ignored; // Ignore because it wont be set anyways. Thumbnails dont have thumbnails.
- PluginResult upload_thumbnail_result = upload_file(room, thumbnail_path, thumbnail_info, upload_info_ignored, err_msg, false);
+ PluginResult upload_thumbnail_result = upload_file(room, thumbnail_path, "", thumbnail_info, upload_info_ignored, err_msg, false);
if(upload_thumbnail_result != PluginResult::OK) {
close(tmp_file);
remove(tmp_filename);
@@ -3771,7 +3771,9 @@ namespace QuickMedia {
{ "--data-binary", "@" + filepath }
};
- const char *filename = file_get_filename(filepath);
+ if(filename.empty())
+ filename = file_get_filename(filepath);
+
std::string filename_escaped = url_param_encode(filename);
char url[512];