bin/xbps-rindex: better error handling for writing repodata archives

This fixes issues when writes fail (as example if the disk is full),
where xbps would create empty repodata or stagedata archives.
This commit is contained in:
Duncan Overbruck authored and Juan RP committed 2019-10-25 23:36:44 +02:00
1 parent 04d5554ed2
commit 7b4a925302
2 files changed
+34 -22

No files matched your search

+6 -2
View File
@@ -83,7 +83,8 @@ xbps_archive_append_buf(struct archive *ar, const void *buf, const size_t buflen
assert(gname);
entry = archive_entry_new();
assert(entry);
if (entry == NULL)
return archive_errno(ar);
archive_entry_set_filetype(entry, AE_IFREG);
archive_entry_set_perm(entry, mode);
@@ -100,7 +101,10 @@ xbps_archive_append_buf(struct archive *ar, const void *buf, const size_t buflen
archive_entry_free(entry);
return archive_errno(ar);
}
archive_write_finish_entry(ar);
if (archive_write_finish_entry(ar) != ARCHIVE_OK) {
archive_entry_free(entry);
return archive_errno(ar);
}
archive_entry_free(entry);
return 0;