Skip to content

Commit

Permalink
YDA-5824: add error logging when creation of archive fails
Browse files Browse the repository at this point in the history
  • Loading branch information
lwesterhof committed Jul 26, 2024
1 parent de3120c commit 4e9b285
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/Archive.hh
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,9 @@ class Archive
archive_entry_set_filetype(entry, AE_IFREG);
archive_entry_set_perm(entry, 0444);
archive_entry_set_size(entry, len);
if (archive_write_header(archive, entry) < 0 || archive_write_data(archive, str, (size_t) len) < 0) {
if (archive_write_header(archive, entry) < ARCHIVE_OK ||
archive_write_data(archive, str, (size_t) len) < ARCHIVE_OK) {
rodsLog(LOG_ERROR, "msiArchiveCreate: %s", archive_error_string(archive));
free(str);
return SYS_TAR_APPEND_ERR;
}
Expand All @@ -303,6 +305,7 @@ class Archive
int fd;
size_t size;
time_t mtime;
int res;

entry = archive_entry_new();
json = json_array_get(list, index);
Expand All @@ -316,7 +319,8 @@ class Archive
*/
archive_entry_set_filetype(entry, AE_IFDIR);
archive_entry_set_perm(entry, 0750);
if (archive_write_header(archive, entry) < 0) {
if (archive_write_header(archive, entry) < ARCHIVE_OK) {
rodsLog(LOG_ERROR, "msiArchiveCreate: %s", archive_error_string(archive));
return SYS_TAR_APPEND_ERR;
}
}
Expand All @@ -328,20 +332,23 @@ class Archive
archive_entry_set_perm(entry, 0600);
size = (size_t) json_integer_value(json_object_get(json, "size"));
archive_entry_set_size(entry, (__LA_INT64_T) size);
if (archive_write_header(archive, entry) < 0) {
if (archive_write_header(archive, entry) < ARCHIVE_OK) {
rodsLog(LOG_ERROR, "msiArchiveCreate: %s", archive_error_string(archive));
return SYS_TAR_APPEND_ERR;
}
fd = _open(data, (origin + "/" + filename).c_str());
if (fd < 0) {
return fd;
}
while ((len = _read(data->rsComm, fd, data->buf, sizeof(data->buf))) > 0) {
if (archive_write_data(archive, data->buf, (size_t) len) < 0) {
if (archive_write_data(archive, data->buf, (size_t) len) < ARCHIVE_OK) {
rodsLog(LOG_ERROR, "msiArchiveCreate: %s", archive_error_string(archive));
_close(data->rsComm, fd);
return SYS_TAR_APPEND_ERR;
}
}
if (len < 0) {
rodsLog(LOG_ERROR, "msiArchiveCreate: Error while reading data object");
_close(data->rsComm, fd);
return SYS_TAR_APPEND_ERR;
}
Expand Down

0 comments on commit 4e9b285

Please sign in to comment.