diff options
| author | Victor Kareh <[email protected]> | 2025-10-02 08:54:41 -0400 |
|---|---|---|
| committer | Victor Kareh <[email protected]> | 2025-10-02 09:00:06 -0400 |
| commit | 112571e109dcac23751caa8e48adad7e412b32eb (patch) | |
| tree | ec717c7d4c9eefa9a98ca6648d4693a8da579fbb | |
| parent | 42237b67b1131f2be4502cde83a02ce534b130af (diff) | |
| download | caja-restore-trashinfo-filename.tar.bz2 caja-restore-trashinfo-filename.tar.xz | |
file-operations: Use correct filename when restoring from Trashrestore-trashinfo-filename
When restoring files from trash, use the original filename from the
.trashinfo file instead of the internal trash filename.
Adapted from Nautilus:
- https://gitlab.gnome.org/GNOME/nautilus/commit/ecee8be8
- https://gitlab.gnome.org/GNOME/nautilus/commit/0d0d95d2
Fixes #1854
| -rw-r--r-- | libcaja-private/caja-file-operations.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/libcaja-private/caja-file-operations.c b/libcaja-private/caja-file-operations.c index 4b51c907..3e4f06e6 100644 --- a/libcaja-private/caja-file-operations.c +++ b/libcaja-private/caja-file-operations.c @@ -3393,6 +3393,28 @@ get_target_file (GFile *src, char *basename; basename = g_file_get_basename (src); + + /* if file is being restored from trash make sure it uses its original name */ + if (g_file_has_uri_scheme (src, "trash")) { + GFileInfo *info; + + info = g_file_query_info (src, + G_FILE_ATTRIBUTE_TRASH_ORIG_PATH, + 0, NULL, NULL); + + if (info) { + const char *orig_path; + + orig_path = g_file_info_get_attribute_byte_string (info, G_FILE_ATTRIBUTE_TRASH_ORIG_PATH); + if (orig_path != NULL) { + g_free (basename); + basename = g_path_get_basename (orig_path); + } + + g_object_unref (info); + } + } + make_file_name_valid_for_dest_fs (basename, dest_fs_type); dest = g_file_get_child (dest_dir, basename); g_free (basename); |
