29
29
private uint mount_timeout_id = 0;
30
30
private const int ENUMERATE_TIMEOUT_SEC = 15;
31
31
private const int QUERY_INFO_TIMEOUT_SEC = 5;
32
private const int MOUNT_TIMEOUT_SEC = 5;
32
private const int MOUNT_TIMEOUT_SEC = 10;
34
34
public GLib.File location;
35
35
public GLib.File? selected_file = null;
89
89
public bool is_trash {get; private set;}
90
90
public bool is_network {get; private set;}
91
91
public bool is_recent {get; private set;}
92
public bool is_no_info {get; private set;}
92
93
public bool has_mounts {get; private set;}
93
94
public bool has_trash_dirs {get; private set;}
94
95
public bool can_load {get; private set;}
113
114
scheme = location.get_uri_scheme ();
114
115
is_trash = (scheme == "trash");
115
116
is_recent = (scheme == "recent");
117
is_no_info = ("cdda mtp".contains (scheme));
116
118
is_local = is_trash || is_recent || (scheme == "file");
117
119
is_network = !is_local && ("ftp sftp afp dav davs".contains (scheme));
118
120
can_open_files = !("mtp".contains (scheme));
167
169
private async void prepare_directory (GOFFileLoadedFunc? file_loaded_func) {
168
170
bool success = yield get_file_info ();
170
if (!file.is_folder () && !file.is_root_network_folder ()) {
172
if (!is_no_info && !file.is_folder () && !file.is_root_network_folder ()) {
171
173
warning ("Trying to load a non-folder - finding parent");
172
174
var parent = file.is_connected ? location.get_parent () : null;
173
175
if (parent != null) {
179
181
warning ("Parent is null for file %s", file.uri);
186
186
warning ("Failed to get file info for file %s", file.uri);
188
yield make_ready (success, file_loaded_func); /* Only place that should call this function */
189
yield make_ready (is_no_info || success, file_loaded_func); /* Only place that should call this function */
192
/*** Returns false if should be able to get info but were unable to ***/
191
193
private async bool get_file_info () {
192
194
/* Force info to be refreshed - the GOF.File may have been created already by another part of the program
193
195
* that did not ensure the correct info Aync purposes, and retrieved from cache (bug 1511307).
195
197
file.info = null;
199
if (is_network && !yield check_network ()) {
200
file.is_connected = false;
205
/* Not a failure when not expected to get file info */
197
210
return file.ensure_query_info ();
199
/* Must be non-local */
200
if (!yield check_network ()) {
201
file.is_connected = false;
204
if (!yield try_query_info ()) { /* may already be mounted */
205
if (yield mount_mountable ()) {
206
/* Previously mounted Samba servers still appear mounted even if disconnected
207
* e.g. by unplugging the network cable. So the following function can block for
208
* a long time; we therefore use a timeout */
209
debug ("successful mount %s", file.uri);
210
return yield try_query_info ();
213
if (!yield try_query_info ()) { /* may already be mounted */
214
if (yield mount_mountable ()) {
215
/* Previously mounted Samba servers still appear mounted even if disconnected
216
* e.g. by unplugging the network cable. So the following function can block for
217
* a long time; we therefore use a timeout */
218
debug ("successful mount %s", file.uri);
219
return yield try_query_info ();
253
262
var mount_op = new Gtk.MountOperation (null);
254
263
cancellable = new Cancellable ();
255
264
bool mounting = true;
265
bool asking_password = false;
256
266
assert (mount_timeout_id == 0);
257
268
mount_timeout_id = Timeout.add_seconds (MOUNT_TIMEOUT_SEC, () => {
269
if (mounting && !asking_password) {
259
270
warning ("Cancelled after timeout in mount mountable %s", file.uri);
260
271
cancellable.cancel ();
272
mount_timeout_id = 0;
262
mount_timeout_id = 0;
279
mount_op.ask_password.connect (() => {
280
asking_password = true;
283
mount_op.reply.connect (() => {
284
asking_password = false;
265
287
yield location.mount_enclosing_volume (0, mount_op, cancellable);
266
288
var mount = location.find_enclosing_mount ();
1101
1124
cancel_timeout (ref timeout_thumbsq);
1102
1125
cancel_timeout (ref idle_consume_changes_id);
1103
1126
cancel_timeout (ref load_timeout_id);
1127
cancel_timeout (ref mount_timeout_id);
1107
1130
private bool cancel_timeout (ref uint id) {