@@ -117,7 +117,6 @@ repo_read_next(struct xbps_repo *repo, struct archive *ar, struct archive_entry
117117 return 0 ;
118118}
119119
120-
121120static int
122121repo_read_index (struct xbps_repo * repo , struct archive * ar )
123122{
@@ -149,15 +148,23 @@ repo_read_index(struct xbps_repo *repo, struct archive *ar)
149148 }
150149
151150 buf = xbps_archive_get_file (ar , entry );
152- if (!buf )
153- return - errno ;
151+ if (!buf ) {
152+ r = - errno ;
153+ xbps_error_printf (
154+ "failed to open repository: %s: failed to read index: %s\n" ,
155+ repo -> uri , strerror (- r ));
156+ return r ;
157+ }
154158 repo -> index = xbps_dictionary_internalize (buf );
155159 r = - errno ;
156160 free (buf );
157161 if (!repo -> index ) {
158- xbps_error_printf ("failed to open repository: %s: reading index: %s\n" ,
162+ if (!r )
163+ r = - EINVAL ;
164+ xbps_error_printf (
165+ "failed to open repository: %s: failed to parse index: %s\n" ,
159166 repo -> uri , strerror (- r ));
160- return - EIO ;
167+ return r ;
161168 }
162169
163170 xbps_dictionary_make_immutable (repo -> index );
@@ -195,7 +202,9 @@ repo_read_meta(struct xbps_repo *repo, struct archive *ar)
195202 buf = xbps_archive_get_file (ar , entry );
196203 if (!buf ) {
197204 r = - errno ;
198- xbps_error_printf ("failed to read repository metadata: %s: %s\n" ,
205+ xbps_error_printf (
206+ "failed to read repository metadata: %s: failed to read "
207+ "metadata: %s\n" ,
199208 repo -> uri , strerror (- r ));
200209 return r ;
201210 }
@@ -208,16 +217,13 @@ repo_read_meta(struct xbps_repo *repo, struct archive *ar)
208217 errno = 0 ;
209218 repo -> idxmeta = xbps_dictionary_internalize (buf );
210219 r = - errno ;
211-
212220 free (buf );
213-
214221 if (!repo -> idxmeta ) {
215- if (!r ) {
216- xbps_error_printf ("failed to read repository metadata: %s: invalid dictionary\n" ,
217- repo -> uri );
218- return - EINVAL ;
219- }
220- xbps_error_printf ("failed to read repository metadata: %s: %s\n" ,
222+ if (!r )
223+ r = - EINVAL ;
224+ xbps_error_printf (
225+ "failed to read repository metadata: %s: failed to parse "
226+ "metadata: %s\n" ,
221227 repo -> uri , strerror (- r ));
222228 return r ;
223229 }
0 commit comments