mirror of
https://github.com/transmission/transmission.git
synced 2025-12-20 02:18:42 +00:00
Adjust Gio::File::query_info() error handling (GTK client) (#4079)
The method never returns `nullptr`, but instead throws if an error occurs. This regressed during the switch from GTK to GTKMM.
This commit is contained in:
@@ -600,16 +600,29 @@ namespace
|
|||||||
|
|
||||||
time_t get_file_mtime(Glib::RefPtr<Gio::File> const& file)
|
time_t get_file_mtime(Glib::RefPtr<Gio::File> const& file)
|
||||||
{
|
{
|
||||||
auto const info = file->query_info(G_FILE_ATTRIBUTE_TIME_MODIFIED);
|
try
|
||||||
return info != nullptr ? info->get_attribute_uint64(G_FILE_ATTRIBUTE_TIME_MODIFIED) : 0;
|
{
|
||||||
|
return file->query_info(G_FILE_ATTRIBUTE_TIME_MODIFIED)->get_attribute_uint64(G_FILE_ATTRIBUTE_TIME_MODIFIED);
|
||||||
|
}
|
||||||
|
catch (Glib::Error const&)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void rename_torrent(Glib::RefPtr<Gio::File> const& file)
|
void rename_torrent(Glib::RefPtr<Gio::File> const& file)
|
||||||
{
|
{
|
||||||
auto const info = file->query_info(G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME);
|
auto info = Glib::RefPtr<Gio::FileInfo>();
|
||||||
|
|
||||||
if (info != nullptr)
|
try
|
||||||
{
|
{
|
||||||
|
info = file->query_info(G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME);
|
||||||
|
}
|
||||||
|
catch (Glib::Error const&)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto const old_name = info->get_attribute_as_string(G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME);
|
auto const old_name = info->get_attribute_as_string(G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME);
|
||||||
auto const new_name = fmt::format("{}.added", old_name);
|
auto const new_name = fmt::format("{}.added", old_name);
|
||||||
|
|
||||||
@@ -628,7 +641,6 @@ void rename_torrent(Glib::RefPtr<Gio::File> const& file)
|
|||||||
g_message("%s", errmsg.c_str());
|
g_message("%s", errmsg.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user