Add priority arg to Geary.Files.recursive_delete_async().
This commit is contained in:
parent
d24720db87
commit
fa3b8fa53f
5 changed files with 51 additions and 26 deletions
|
|
@ -555,11 +555,15 @@ public class AccountManager : GLib.Object {
|
|||
GLib.Cancellable? cancellable)
|
||||
throws GLib.Error {
|
||||
if (info.data_dir != null) {
|
||||
yield Geary.Files.recursive_delete_async(info.data_dir, cancellable);
|
||||
yield Geary.Files.recursive_delete_async(
|
||||
info.data_dir, GLib.Priority.DEFAULT, cancellable
|
||||
);
|
||||
}
|
||||
|
||||
if (info.config_dir != null) {
|
||||
yield Geary.Files.recursive_delete_async(info.config_dir, cancellable);
|
||||
yield Geary.Files.recursive_delete_async(
|
||||
info.config_dir, GLib.Priority.DEFAULT, cancellable
|
||||
);
|
||||
}
|
||||
|
||||
SecretMediator? mediator = info.imap.mediator as SecretMediator;
|
||||
|
|
|
|||
|
|
@ -229,17 +229,25 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
|
|||
File attachments_dir;
|
||||
ImapDB.Account.get_imap_db_storage_locations(information.data_dir, out db_file,
|
||||
out attachments_dir);
|
||||
|
||||
|
||||
if (yield Files.query_exists_async(db_file, cancellable)) {
|
||||
message("%s: Deleting database file %s...", to_string(), db_file.get_path());
|
||||
yield db_file.delete_async(Priority.DEFAULT, cancellable);
|
||||
message(
|
||||
"%s: Deleting database file %s...",
|
||||
to_string(), db_file.get_path()
|
||||
);
|
||||
yield db_file.delete_async(GLib.Priority.DEFAULT, cancellable);
|
||||
}
|
||||
|
||||
|
||||
if (yield Files.query_exists_async(attachments_dir, cancellable)) {
|
||||
message("%s: Deleting attachments directory %s...", to_string(), attachments_dir.get_path());
|
||||
yield Files.recursive_delete_async(attachments_dir, cancellable);
|
||||
message(
|
||||
"%s: Deleting attachments directory %s...",
|
||||
to_string(), attachments_dir.get_path()
|
||||
);
|
||||
yield Files.recursive_delete_async(
|
||||
attachments_dir, GLib.Priority.DEFAULT, cancellable
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
message("%s: Rebuild complete", to_string());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,9 @@ private const int RECURSIVE_DELETE_BATCH_SIZE = 50;
|
|||
* This method is designed to keep chugging along even if an error occurs.
|
||||
* If this method is called with a file, it will simply be deleted.
|
||||
*/
|
||||
public async void recursive_delete_async(File folder, Cancellable? cancellable = null) {
|
||||
public async void recursive_delete_async(GLib.File folder,
|
||||
int priority = GLib.Priority.DEFAULT,
|
||||
GLib.Cancellable? cancellable = null) {
|
||||
// If this is a folder, recurse children.
|
||||
FileType file_type = FileType.UNKNOWN;
|
||||
try {
|
||||
|
|
@ -29,8 +31,12 @@ public async void recursive_delete_async(File folder, Cancellable? cancellable =
|
|||
if (file_type == FileType.DIRECTORY) {
|
||||
FileEnumerator? enumerator = null;
|
||||
try {
|
||||
enumerator = yield folder.enumerate_children_async(FileAttribute.STANDARD_NAME,
|
||||
FileQueryInfoFlags.NOFOLLOW_SYMLINKS, Priority.DEFAULT, cancellable);
|
||||
enumerator = yield folder.enumerate_children_async(
|
||||
FileAttribute.STANDARD_NAME,
|
||||
FileQueryInfoFlags.NOFOLLOW_SYMLINKS,
|
||||
priority,
|
||||
cancellable
|
||||
);
|
||||
} catch (Error e) {
|
||||
debug("Error enumerating files for deletion: %s", e.message);
|
||||
}
|
||||
|
|
@ -39,14 +45,22 @@ public async void recursive_delete_async(File folder, Cancellable? cancellable =
|
|||
if (enumerator != null) {
|
||||
try {
|
||||
while (true) {
|
||||
List<FileInfo>? info_list = yield enumerator.next_files_async(RECURSIVE_DELETE_BATCH_SIZE,
|
||||
Priority.DEFAULT, cancellable);
|
||||
List<FileInfo>? info_list = yield enumerator.next_files_async(
|
||||
RECURSIVE_DELETE_BATCH_SIZE,
|
||||
priority,
|
||||
cancellable
|
||||
);
|
||||
if (info_list == null)
|
||||
break; // Stop condition.
|
||||
|
||||
|
||||
// Recursive step.
|
||||
foreach (FileInfo info in info_list)
|
||||
yield recursive_delete_async(folder.get_child(info.get_name()), cancellable);
|
||||
foreach (FileInfo info in info_list) {
|
||||
yield recursive_delete_async(
|
||||
folder.get_child(info.get_name()),
|
||||
priority,
|
||||
cancellable
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (Error e) {
|
||||
debug("Error enumerating batch of files: %s", e.message);
|
||||
|
|
@ -56,10 +70,10 @@ public async void recursive_delete_async(File folder, Cancellable? cancellable =
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Children have been deleted, it's now safe to delete this file/folder.
|
||||
try {
|
||||
yield folder.delete_async(Priority.DEFAULT, cancellable);
|
||||
yield folder.delete_async(priority, cancellable);
|
||||
} catch (Error e) {
|
||||
debug("Error removing file: %s", e.message);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -144,12 +144,11 @@ CREATE TABLE MessageAttachmentTable (
|
|||
this.db.close();
|
||||
this.db = null;
|
||||
|
||||
Geary.Files.recursive_delete_async.begin(
|
||||
this.tmp_dir,
|
||||
null,
|
||||
Files.recursive_delete_async.begin(
|
||||
this.tmp_dir, GLib.Priority.DEFAULT, null,
|
||||
(obj, res) => { async_complete(res); }
|
||||
);
|
||||
Geary.Files.recursive_delete_async.end(async_result());
|
||||
Files.recursive_delete_async.end(async_result());
|
||||
this.tmp_dir = null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -121,11 +121,11 @@ class Geary.ImapDB.DatabaseTest : TestCase {
|
|||
// Need to close it again to stop the GC process running
|
||||
db.close();
|
||||
|
||||
Geary.Files.recursive_delete_async.begin(
|
||||
tmp_dir, null,
|
||||
Files.recursive_delete_async.begin(
|
||||
tmp_dir, GLib.Priority.DEFAULT, null,
|
||||
(obj, res) => { async_complete(res); }
|
||||
);
|
||||
Geary.Files.recursive_delete_async.end(async_result());
|
||||
Files.recursive_delete_async.end(async_result());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue