GFile can still obtain the mount path of samba which have been unmounted already
I wrote a demo to mount samba and ftp connections, and I mount them with the function GFile::g_file_mount_enclosing_volume
.
this is the main code:
auto uri = ui->editUri->text();
GFile_autoptr file = g_file_new_for_uri(uri.toStdString().c_str());
if (!file) {
qDebug() << "cannot create file!" << uri;
ui->editOutput->appendPlainText("[error] cannot create file via " + uri);
return;
}
// here is the problem code, when I trigger this function twice, first time it is mounted successfully,
// and tried mount again, then this condition went in.
// after this, unmount by execute command : gio mount smb://127.0.0.1/wallpapers -u
// and unmount successfully.
// after that, mount it again, this code block was executed.
// i'm not sure whether this is a bug of the GIO.
g_autofree char *mntPath = g_file_get_path(file);
if (mntPath) {
ui->editOutput->appendPlainText("[error] " + uri + " is already mounted at " + mntPath);
return;
}
GMountOperation_autoptr op = g_mount_operation_new();
g_signal_connect(op, "ask_password", G_CALLBACK(&MainWindow::askPasswd), this);
g_file_mount_enclosing_volume(file, G_MOUNT_MOUNT_NONE, op, nullptr, &MainWindow::mountFinished, this);
I invoke this function twice, the first time it was mounted successfully, and then invoked it again. and if (mntPath)
code block was invoked.
after the operation, unmount the mount with command gio mount smb://127.0.0.1/wallpapers -u
, we can see this mount no longer exists in Nautilus' sidebar, that was unmounted successfully.
then I invoke mount again, something weired happened. the video in attached files shows the phenomenon. also the demo code is in the archive.
please take a look and tell me if it is resovled already in the newest version of glib.
thanks
here is the version of glib:
~ ᐅ gio version
2.58.3
~ ᐅ dpkg -l | grep libglib2.0-dev
ii libglib2.0-dev:amd64 2.58.3.6-1+eagle amd64 Development files for the GLib library
ii libglib2.0-dev-bin 2.58.3.6-1+eagle amd64 Development utilities for the GLib library
Edited by St Xu