Merge branch 'mjog/1147-startup-warning' into 'mainline'
Startup directory not found warning See merge request GNOME/geary!662
This commit is contained in:
commit
2e56aeda90
2 changed files with 30 additions and 48 deletions
|
|
@ -195,9 +195,13 @@ internal class Application.Controller :
|
|||
// Commit e8061379 mistakenly used config_dir for cert manager
|
||||
// above, so remove it if found. This can be pulled out post
|
||||
// v40.
|
||||
yield Geary.Files.recursive_delete_async(
|
||||
config_dir.get_child("pinned-certs")
|
||||
);
|
||||
try {
|
||||
yield Geary.Files.recursive_delete_async(
|
||||
config_dir.get_child("pinned-certs")
|
||||
);
|
||||
} catch (GLib.IOError.NOT_FOUND err) {
|
||||
// exactly as planned
|
||||
}
|
||||
|
||||
SecretMediator? libsecret = yield new SecretMediator(cancellable);
|
||||
|
||||
|
|
|
|||
|
|
@ -16,67 +16,45 @@ private const int RECURSIVE_DELETE_BATCH_SIZE = 50;
|
|||
*/
|
||||
public async void recursive_delete_async(GLib.File folder,
|
||||
int priority = GLib.Priority.DEFAULT,
|
||||
GLib.Cancellable? cancellable = null) {
|
||||
GLib.Cancellable? cancellable = null)
|
||||
throws GLib.Error {
|
||||
GLib.FileType type = yield query_file_type_async(folder, true, cancellable);
|
||||
|
||||
// If this is a folder, recurse children.
|
||||
FileType file_type = FileType.UNKNOWN;
|
||||
try {
|
||||
file_type = yield query_file_type_async(folder, true, cancellable);
|
||||
} catch (Error err) {
|
||||
debug("Unable to get file type of %s: %s", folder.get_path(), err.message);
|
||||
|
||||
if (err is IOError.CANCELLED)
|
||||
return;
|
||||
}
|
||||
|
||||
if (file_type == FileType.DIRECTORY) {
|
||||
FileEnumerator? enumerator = null;
|
||||
try {
|
||||
enumerator = yield folder.enumerate_children_async(
|
||||
if (type == DIRECTORY) {
|
||||
FileEnumerator? enumerator = yield folder.enumerate_children_async(
|
||||
FileAttribute.STANDARD_NAME,
|
||||
FileQueryInfoFlags.NOFOLLOW_SYMLINKS,
|
||||
NOFOLLOW_SYMLINKS,
|
||||
priority,
|
||||
cancellable
|
||||
);
|
||||
} catch (Error e) {
|
||||
debug("Error enumerating files for deletion: %s", e.message);
|
||||
}
|
||||
);
|
||||
|
||||
// Iterate the enumerated files in batches.
|
||||
if (enumerator != null) {
|
||||
try {
|
||||
while (true) {
|
||||
List<FileInfo>? info_list = yield enumerator.next_files_async(
|
||||
RECURSIVE_DELETE_BATCH_SIZE,
|
||||
while (true) {
|
||||
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()),
|
||||
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()),
|
||||
priority,
|
||||
cancellable
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (Error e) {
|
||||
debug("Error enumerating batch of files: %s", e.message);
|
||||
|
||||
if (e is IOError.CANCELLED)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Children have been deleted, it's now safe to delete this file/folder.
|
||||
try {
|
||||
yield folder.delete_async(priority, cancellable);
|
||||
} catch (Error e) {
|
||||
debug("Error removing file: %s", e.message);
|
||||
}
|
||||
yield folder.delete_async(priority, cancellable);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue