Commit e525ba70 authored by Michael Terry's avatar Michael Terry

BackendFile: Switch a sync call to an async call

This avoids blocking when mounting a GFile location.
parent 9c8eec1f
...@@ -124,6 +124,19 @@ public abstract class BackendFile : Backend ...@@ -124,6 +124,19 @@ public abstract class BackendFile : Backend
this.unref(); this.unref();
} }
async bool query_exists_async(File file)
{
try {
yield file.query_info_async(FileAttribute.STANDARD_TYPE,
FileQueryInfoFlags.NONE,
Priority.DEFAULT, null);
return true;
}
catch (Error e) {
return false;
}
}
async void do_mount() throws Error async void do_mount() throws Error
{ {
yield mount(); yield mount();
...@@ -135,7 +148,7 @@ public abstract class BackendFile : Backend ...@@ -135,7 +148,7 @@ public abstract class BackendFile : Backend
// as they allow multiple files with the same name. Querying it // as they allow multiple files with the same name. Querying it
// anchors the path to the backend object and we don't create a second // anchors the path to the backend object and we don't create a second
// copy this way. // copy this way.
if (gfile != null && !gfile.query_exists()) { if (gfile != null && !(yield query_exists_async(gfile))) {
try { try {
gfile.make_directory_with_parents (null); gfile.make_directory_with_parents (null);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment