~jeremywootten/pantheon-files/fix-backspace-in-columnv-view

« back to all changes in this revision

Viewing changes to libcore/gof-directory-async.vala

merge various-fixes-part4-fix-network-drag-drop-copy-paste r2049

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
    private List<unowned GOF.File>? sorted_dirs = null;
57
57
 
58
58
    public signal void file_loaded (GOF.File file);
59
 
    public signal void file_added (GOF.File file);
 
59
    public signal void file_added (GOF.File? file); /* null used to signal failed operation */
60
60
    public signal void file_changed (GOF.File file);
61
61
    public signal void file_deleted (GOF.File file);
62
62
    public signal void icon_changed (GOF.File file); /* Called directly by GOF.File - handled by AbstractDirectoryView
157
157
    private async void prepare_directory (GOFFileLoadedFunc? file_loaded_func) {
158
158
        bool success = yield get_file_info ();
159
159
        if (success) {
160
 
            if (is_local && !file.is_folder ()) {
 
160
            if (!file.is_folder () && !file.is_root_network_folder ()) {
 
161
                warning ("Trying to load a non-folder - finding parent");
161
162
                var parent = file.is_connected ? location.get_parent () : null;
162
163
                if (parent != null) {
163
164
                    file = GOF.File.get (parent);
165
166
                    location = parent;
166
167
                    success = yield get_file_info ();
167
168
                } else {
 
169
                    warning ("Parent is null for file %s", file.uri);
168
170
                    success = false;
169
171
                }
 
172
            } else {
 
173
 
170
174
            }
 
175
        } else {
 
176
            warning ("Failed to get file info for file %s", file.uri);
171
177
        }
172
178
        make_ready (success, file_loaded_func); /* Only place that should call this function */
173
179
    }
180
186
        if (is_local) {
181
187
            return file.ensure_query_info ();
182
188
        }
183
 
 
184
189
        /* Must be non-local */
185
190
        if (!is_local && !yield check_network ()) {
186
191
            file.is_connected = false;
225
230
        }
226
231
        if (success) {
227
232
            debug ("got file info");
228
 
            file.ensure_query_info ();
 
233
            file.update ();
229
234
            return true;
230
235
        } else {
231
 
            debug ("Failed to get file info for %s", file.uri);
 
236
            warning ("Failed to get file info for %s", file.uri);
232
237
            return false;
233
238
        }
234
239
    }
246
251
                file.is_connected = true;
247
252
            } else {
248
253
                file.is_connected = false;
 
254
                file.is_mounted = false;
249
255
                warning ("Mount_mountable failed: %s", e.message);
250
256
                if (e is IOError.PERMISSION_DENIED || e is IOError.FAILED_HANDLED) {
251
257
                    permission_denied = true;
292
298
    private void make_ready (bool ready, GOFFileLoadedFunc? file_loaded_func = null) {
293
299
        can_load = ready;
294
300
        if (!can_load) {
295
 
            debug ("%s cannot load", file.uri);
 
301
            warning ("%s cannot load.  Connected %s, Mounted %s, Exists %s", file.uri,
 
302
                                                                             file.is_connected.to_string (),
 
303
                                                                             file.is_mounted.to_string (),
 
304
                                                                             file.exists.to_string ());
296
305
            state = State.NOT_LOADED; /* ensure state is correct */
297
306
            done_loading ();
298
307
            return;
375
384
    public void cancel () {
376
385
        /* This should only be called when closing the view - it will cancel initialisation of the directory */
377
386
        cancellable.cancel ();
378
 
        cancel_thumbnailing ();
379
 
        cancel_timeout (ref load_timeout_id);
380
 
        cancel_timeout (ref idle_consume_changes_id);
 
387
        cancel_timeouts ();
381
388
    }
382
389
 
383
390
    public void cancel_thumbnailing () {
384
391
        /* remove any pending thumbnail generation */
385
 
        if (timeout_thumbsq != 0) {
386
 
            Source.remove (timeout_thumbsq);
387
 
            timeout_thumbsq = 0;
388
 
        }
 
392
        cancel_timeout (ref timeout_thumbsq);
389
393
    }
390
394
 
391
395
    public void reload () {
620
624
                                                            FileQueryInfoFlags.NONE,
621
625
                                                            Priority.DEFAULT,
622
626
                                                            cancellable);
623
 
            if (f != null)
 
627
            if (f != null) {
624
628
                f (gof);
 
629
            }
625
630
        } catch (Error err) {
626
631
            warning ("query info failed, %s %s", err.message, gof.uri);
627
632
            if (err is IOError.NOT_FOUND) {
632
637
    }
633
638
 
634
639
    private void changed_and_refresh (GOF.File gof) {
635
 
        if (gof.is_gone)
 
640
        if (gof.is_gone) {
 
641
            warning ("File marked as gone when refreshing change");
636
642
            return;
 
643
        }
637
644
 
638
645
        gof.update ();
639
646
 
644
651
    }
645
652
 
646
653
    private void add_and_refresh (GOF.File gof) {
647
 
        if (gof.is_gone)
 
654
        if (gof.is_gone) {
 
655
            warning ("Add and refresh file which is gone");
648
656
            return;
649
 
 
 
657
        }
650
658
        if (gof.info == null)
651
659
            critical ("FILE INFO null");
652
660
 
814
822
 
815
823
                if (!found)
816
824
                    dirs.append (dir);
 
825
            } else {
 
826
                warning ("parent of deleted file not found");
817
827
            }
818
828
        }
819
829
 
1043
1053
        timeout_thumbsq = Timeout.add (40, queue_thumbs_timeout_cb);
1044
1054
    }
1045
1055
 
 
1056
    private void cancel_timeouts () {
 
1057
        cancel_timeout (ref timeout_thumbsq);
 
1058
        cancel_timeout (ref idle_consume_changes_id);
 
1059
        cancel_timeout (ref load_timeout_id);
 
1060
        
 
1061
    }
 
1062
 
1046
1063
    private bool cancel_timeout (ref uint id) {
1047
1064
        if (id > 0) {
1048
1065
            Source.remove (id);