[gnome-commander] When creating a new GnomeCmdDir object from GFileInfo, try to get a gFile for it.
- From: Uwe Scholz <uwescholz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander] When creating a new GnomeCmdDir object from GFileInfo, try to get a gFile for it.
- Date: Fri, 29 Oct 2021 21:19:44 +0000 (UTC)
commit 45b00ff2c19d57a776ed5906a70470afce6b1464
Author: Uwe Scholz <u scholz83 gmx de>
Date: Fri Oct 29 23:06:52 2021 +0200
When creating a new GnomeCmdDir object from GFileInfo, try to get a gFile for it.
This gFile is used to check if the object is already existing in the lookup cache.
For remote directories this did not work before because the URI was always with
a local scheme.
src/gnome-cmd-dir.cc | 56 +++++++++++++++++++++++++++++++++-------------------
1 file changed, 36 insertions(+), 20 deletions(-)
---
diff --git a/src/gnome-cmd-dir.cc b/src/gnome-cmd-dir.cc
index 22d4aa4f..e7e80e4f 100644
--- a/src/gnome-cmd-dir.cc
+++ b/src/gnome-cmd-dir.cc
@@ -239,43 +239,59 @@ static void gnome_cmd_dir_class_init (GnomeCmdDirClass *klass)
* Public functions
***********************************/
-GnomeCmdDir *gnome_cmd_dir_new_from_gfileinfo (GFileInfo *gFileInfo, GnomeCmdDir *parent)
+GnomeCmdDir *gnome_cmd_dir_new_from_gfileinfo (GFileInfo *gFileInfo, GnomeCmdDir *gnomeCmdDirParent)
{
g_return_val_if_fail (gFileInfo != nullptr, nullptr);
- g_return_val_if_fail (GNOME_CMD_IS_DIR (parent), nullptr);
+ g_return_val_if_fail (GNOME_CMD_IS_DIR (gnomeCmdDirParent), nullptr);
- GnomeCmdCon *con = gnome_cmd_dir_get_connection (parent);
- auto basename = g_file_info_get_display_name(gFileInfo);
- GnomeCmdPath *path = gnome_cmd_dir_get_path (parent)->get_child(basename);
- if (!path)
+ GnomeCmdCon *con = gnome_cmd_dir_get_connection (gnomeCmdDirParent);
+ auto dirName = g_file_info_get_name(gFileInfo);
+
+ GFile *gFile = nullptr;
+ GnomeCmdPath *dirPath = nullptr;
+
+ gFile = gnome_cmd_dir_get_gfile_for_con_and_filename(gnomeCmdDirParent, dirName);
+ if (gFile)
{
- return nullptr;
+ auto uriStringTmp = g_file_get_uri(gFile);
+ auto uriTmp = g_uri_parse(uriStringTmp, G_URI_FLAGS_NONE, nullptr);
+ auto pathTmp = g_uri_get_path(uriTmp);
+ dirPath = gnome_cmd_con_create_path(con, pathTmp);
+ g_free(uriStringTmp);
}
+ else
+ {
+ dirPath = gnome_cmd_dir_get_path (gnomeCmdDirParent)->get_child(dirName);
+ if (!dirPath)
+ {
+ return nullptr;
+ }
- auto gFile = gnome_cmd_con_create_gfile (con, path);
+ gFile = gnome_cmd_con_create_gfile (con, dirPath);
+ }
auto uriString = g_file_get_uri (gFile);
- GnomeCmdDir *dir = gnome_cmd_con_cache_lookup (gnome_cmd_dir_get_connection (parent), uriString);
+ auto *gnomeCmdDir = gnome_cmd_con_cache_lookup (gnome_cmd_dir_get_connection (gnomeCmdDirParent),
uriString);
g_object_unref (gFile);
- if (dir)
+ if (gnomeCmdDir)
{
- delete path;
- GNOME_CMD_FILE (dir)->update_gFileInfo(gFileInfo);
+ delete dirPath;
+ reinterpret_cast<GnomeCmdFile*>((gnomeCmdDir))->update_gFileInfo(gFileInfo);
g_free (uriString);
- return dir;
+ return gnomeCmdDir;
}
- dir = static_cast<GnomeCmdDir*> (g_object_new (GNOME_CMD_TYPE_DIR, nullptr));
- gnome_cmd_file_setup (G_OBJECT (dir), gFileInfo, parent);
+ gnomeCmdDir = static_cast<GnomeCmdDir*> (g_object_new (GNOME_CMD_TYPE_DIR, nullptr));
+ gnome_cmd_file_setup (G_OBJECT (gnomeCmdDir), gFileInfo, gnomeCmdDirParent);
- dir->priv->con = con;
- gnome_cmd_dir_set_path (dir, path);
- dir->priv->needs_mtime_update = FALSE;
+ gnomeCmdDir->priv->con = con;
+ gnome_cmd_dir_set_path (gnomeCmdDir, dirPath);
+ gnomeCmdDir->priv->needs_mtime_update = FALSE;
- gnome_cmd_con_add_to_cache (gnome_cmd_dir_get_connection (parent), dir, uriString);
+ gnome_cmd_con_add_to_cache (gnome_cmd_dir_get_connection (gnomeCmdDirParent), gnomeCmdDir, uriString);
- return dir;
+ return gnomeCmdDir;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]