fix: Improve status reporting and filename handling for /url save

Use the original aesgcm:// URL when downloading OMEMO downloads.  Then
in the final message use the decrypted file destination instead of the
internal temporary path.

Use the unique download ID instead of the URL for message updates to
have proper progress reporting.

Unify the final transfer status to "done" across both downloads and
uploads.

Fixes: https://github.com/profanity-im/profanity/issues/1939
Signed-off-by: Michael Vetter <jubalh@iodoru.org>
This commit is contained in:
Michael Vetter
2026-03-24 21:20:24 +00:00
parent 050096c21e
commit a9ef000328
5 changed files with 55 additions and 24 deletions

View File

@@ -9209,18 +9209,30 @@ _prepare_filename(ProfWin* window, gchar* url, gchar* path)
break;
}
// Ensure that the downloads directory exists for saving cleartexts.
auto_gchar gchar* downloads_dir = path ? get_expanded_path(path) : files_get_download_path(jid);
if (g_mkdir_with_parents(downloads_dir, S_IRWXU) != 0) {
cons_show_error("Failed to create download directory "
"at '%s' with error '%s'",
downloads_dir, strerror(errno));
return NULL;
auto_gchar gchar* expanded_path = path ? get_expanded_path(path) : files_get_download_path(jid);
// If path is provided and doesn't look like a directory, create its parent.
// Otherwise, create the directory itself.
if (path && !g_str_has_suffix(expanded_path, G_DIR_SEPARATOR_S) && !g_file_test(expanded_path, G_FILE_TEST_IS_DIR)) {
auto_gchar gchar* dirname = g_path_get_dirname(expanded_path);
if (g_mkdir_with_parents(dirname, S_IRWXU) != 0) {
cons_show_error("Failed to create download directory "
"at '%s' with error '%s'",
dirname, strerror(errno));
return NULL;
}
} else {
if (g_mkdir_with_parents(expanded_path, S_IRWXU) != 0) {
cons_show_error("Failed to create download directory "
"at '%s' with error '%s'",
expanded_path, strerror(errno));
return NULL;
}
}
// Generate an unique filename from the URL that should be stored in the
// downloads directory.
return unique_filename_from_url(url, downloads_dir);
return unique_filename_from_url(url, expanded_path);
}
#ifdef HAVE_OMEMO