diff options
author | Benjamin Otte <otte@redhat.com> | 2010-02-25 12:09:36 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2010-02-26 16:32:04 +0100 |
commit | 483db9169ab96b0599a94b3f5887fb320b84175d (patch) | |
tree | 3e73313aafe00b253d36fbadc97ff45a0062a33b /daemon | |
parent | aaccec1ea490fdef9c38a2324e081ef7015f4655 (diff) | |
download | gvfs-483db9169ab96b0599a94b3f5887fb320b84175d.tar.gz |
archive: Use archive_errno() the correct way
Previous code was assuming that archive_errno() would report the last
error that happened or SUCCESS if none. This is not true, however as the
return value of archive_errno() is undefined if no error happened.
This patch changes it to only call archive_errno() after errors.
https://bugzilla.gnome.org/show_bug.cgi?id=611057
Diffstat (limited to 'daemon')
-rw-r--r-- | daemon/gvfsbackendarchive.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/daemon/gvfsbackendarchive.c b/daemon/gvfsbackendarchive.c index 43fe999c..24547441 100644 --- a/daemon/gvfsbackendarchive.c +++ b/daemon/gvfsbackendarchive.c @@ -160,6 +160,18 @@ gvfs_archive_close (struct archive *archive, #define gvfs_archive_in_error(archive) ((archive)->error != NULL) +static void +gvfs_archive_set_error_from_errno (GVfsArchive *archive) +{ + if (gvfs_archive_in_error (archive)) + return; + + g_vfs_job_failed_literal (archive->job, + G_IO_ERROR, + g_io_error_from_errno (archive_errno (archive->archive)), + archive_error_string (archive->archive)); +} + static void gvfs_archive_push_job (GVfsArchive *archive, GVfsJob *job) { @@ -178,13 +190,6 @@ gvfs_archive_pop_job (GVfsArchive *archive) g_vfs_job_failed_from_error (archive->job, archive->error); g_clear_error (&archive->error); } - else if (archive_errno (archive->archive)) - { - g_vfs_job_failed_literal (archive->job, - G_IO_ERROR, - archive_errno (archive->archive), - archive_error_string (archive->archive)); - } else g_vfs_job_succeeded (archive->job); @@ -479,6 +484,8 @@ create_file_tree (GVfsBackendArchive *ba, GVfsJob *job) } while (result != ARCHIVE_FATAL && result != ARCHIVE_EOF); + if (result == ARCHIVE_FATAL) + gvfs_archive_set_error_from_errno (archive); fixup_dirs (ba->files); gvfs_archive_finish (archive); @@ -688,6 +695,8 @@ do_read (GVfsBackend *backend, bytes_read = archive_read_data (archive->archive, buffer, bytes_requested); if (bytes_read >= 0) g_vfs_job_read_set_size (job, bytes_read); + else + gvfs_archive_set_error_from_errno (archive); gvfs_archive_pop_job (archive); } |