Browse Source

Do not attempt to mount an already mounted volume

Before attempting to mount a GIO-backed volume, check if it is not
already mounted. Once the file has been retrieved, unmount the
volume only if we mounted it, but leave it mounted if it already was.
develop
Damien Goutte-Gattat 5 years ago
parent
commit
5707dd094b
  1. 13
      src/uuid-support.c

13
src/uuid-support.c

@ -182,9 +182,13 @@ get_file_contents(GVolume *volume,
GMount *mount;
GFile *root;
char *root_path, *full_path;
int rc = -1;
int was_mounted, rc = -1;
if ( (mount = mount_volume(volume)) == NULL )
if ( (mount = g_volume_get_mount(volume)) )
was_mounted = 1;
else if ( (mount = mount_volume(volume)) )
was_mounted = 0;
else
return -1;
root = g_mount_get_root(mount);
@ -194,7 +198,10 @@ get_file_contents(GVolume *volume,
if ( (*buffer = read_file(full_path, len)) )
rc = 0;
unmount_volume(mount);
if ( was_mounted )
g_object_unref(mount);
else
unmount_volume(mount);
g_free(full_path);
g_free(root_path);

Loading…
Cancel
Save