diff options
author | Mohamed AMAZIRH <m.amazirh@gmail.com> | 2022-01-15 19:22:07 +0100 |
---|---|---|
committer | Mohamed AMAZIRH <m.amazirh@gmail.com> | 2022-01-15 19:44:07 +0100 |
commit | b8de85f48d64b69768f80d0d2faec30ef95fab9a (patch) | |
tree | 74af91fccca82804abaca82fae36681703379da1 /thunar | |
parent | bf7413759cecaf1072ec5cbf5882364f034bb987 (diff) | |
download | thunar-b8de85f48d64b69768f80d0d2faec30ef95fab9a.tar.gz |
Skip files with IO errors during directory scan (Issue #696)
This is needed to avoid the user ending up with an empty directory when that directory contains a corrupted file or a disconnected network drive/mount.
Thunar will display only the accessible files and skip the ones with IO errors.
No error message will be shown to the user.
This new behaviour is similar to Nautilus & Pacman File Manager behaviours in the same situation
Diffstat (limited to 'thunar')
-rw-r--r-- | thunar/thunar-io-scan-directory.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/thunar/thunar-io-scan-directory.c b/thunar/thunar-io-scan-directory.c index bc14628b..7b1867f4 100644 --- a/thunar/thunar-io-scan-directory.c +++ b/thunar/thunar-io-scan-directory.c @@ -112,7 +112,8 @@ thunar_io_scan_directory (ThunarJob *job, /* query info of the child */ info = g_file_enumerator_next_file (enumerator, cancellable, &err); - if (G_UNLIKELY (info == NULL)) + /* break when end of enumerator is reached */ + if (G_UNLIKELY (info == NULL && err == NULL)) break; is_mounted = TRUE; @@ -125,8 +126,23 @@ thunar_io_scan_directory (ThunarJob *job, } else { - /* break on errors */ - break; + if (info != NULL) + g_warning ("Error while scanning file: %s : %s", g_file_info_get_display_name (info), err->message); + else + g_warning ("Error while scanning directory: %s : %s", g_file_get_uri (file), err->message); + + if (g_error_matches(err, G_IO_ERROR, G_IO_ERROR_FAILED)) + { + /* ignore any other IO error and continue processing the + * remaining files */ + g_clear_error(&err); + continue; + } + else + { + /* break on other errors */ + break; + } } } |