Merge FS_Info load cache calls (#131)

Now FS_Info::load_cache() and ::load_cache_for_paths() are nearly next
to each other, merge them together to simplify the code a little.  This
makes the special case to ensure that file system images named on the
command line were queried by blkid and loaded into the FS_Info cache [1]
become the normal cache loading method.  Already passing all discovered
or named devices to load_cache_for_paths() is also a step on the way to
doing it for all devices and partitions of interest.

Just need to ensure that load_cache_for_paths() always loads the cache
as load_cache() did, rather than only when it hadn't already been
loaded.  Otherwise GParted will only ever run blkid and load the cache
once at startup and not on each refresh.

[1] e8f0504b13
    Make sure that FS_Info cache is loaded for all named paths (#787181)

Closes #131 - GParted hangs when non-named device is hung
This commit is contained in:
Mike Fleetwood 2021-01-19 20:22:25 +00:00 committed by Curtis Gedak
parent a8cd7a4e80
commit 45f88c3274
3 changed files with 3 additions and 12 deletions

View File

@ -38,7 +38,6 @@ struct FS_Entry
class FS_Info
{
public:
static void load_cache();
static void load_cache_for_paths( const std::vector<Glib::ustring> &device_paths );
static Glib::ustring get_fs_type( const Glib::ustring & path );
static Glib::ustring get_label( const Glib::ustring & path, bool & found );

View File

@ -49,16 +49,13 @@ bool FS_Info::need_blkid_vfat_cache_update_workaround = true;
// ]
std::vector<FS_Entry> FS_Info::fs_info_cache;
void FS_Info::load_cache()
void FS_Info::load_cache_for_paths( const std::vector<Glib::ustring> &device_paths )
{
set_commands_found();
load_fs_info_cache();
fs_info_cache_initialized = true;
}
void FS_Info::load_cache_for_paths( const std::vector<Glib::ustring> &device_paths )
{
initialize_if_required();
const BlockSpecial empty_bs = BlockSpecial();
for ( unsigned int i = 0 ; i < device_paths.size() ; i ++ )
{

View File

@ -248,18 +248,13 @@ void GParted_Core::set_devices_thread( std::vector<Device> * pdevices )
}
// Initialise and load caches needed for content discovery.
FS_Info::load_cache(); // Cache of file system details from blkid.
FS_Info::load_cache_for_paths(device_paths);
Mount_Info::load_cache();
LVM2_PV_Info::clear_cache();
btrfs::clear_cache();
SWRaid_Info::load_cache();
LUKS_Info::clear_cache();
// Ensure all named paths have FS_Info blkid cache entries specifically so that
// command line named file system image files, which blkid can't otherwise know
// about, can be identified.
FS_Info::load_cache_for_paths( device_paths );
for ( unsigned int t = 0 ; t < device_paths .size() ; t++ )
{
/*TO TRANSLATORS: looks like Searching /dev/sda partitions */