SMB doesn't set G_FILE_ATTRIBUTE_ACCESS_ file attributes
Submitted by kde..@..il.com
Assigned to gvf..@..e.bugs
Link to original bug (#581368)
Description
Please describe the problem: I was trying to see if an smb uri was readable using the g_file_info_get_attribute_boolean method, works fine for sftp and local files, but fails for smb mounts
Steps to reproduce:
- See example code below
Actual results: Returns false for file opened off of an smb share
Expected results: should return true, works ok in nautilus
Does this happen every time? yes, and on other system levels
Other information: Example code with workaround
file = g_file_new_for_uri(uri);
if (file != NULL) {
info = g_file_query_info(file, "*", G_FILE_QUERY_INFO_NONE, NULL, NULL);
if (info != NULL) {
// SMB filesystems seem to give incorrect access answers over GIO,
// so if the file has a filesize > 0 we think it is not streaming
if (g_ascii_strncasecmp(uri, "smb://", strlen("smb://")) == 0) {
ret = (g_file_info_get_size(info) > 0) ? FALSE : TRUE;
} else {
ret =
!g_file_info_get_attribute_boolean(info, G_FILE_ATTRIBUTE_ACCESS_CAN_READ);
}
g_object_unref(info);
} else {
ret = !g_file_test(uri, G_FILE_TEST_EXISTS);
}
}
g_object_unref(file);
Version: 1.2.x