summaryrefslogtreecommitdiff
path: root/libarchive/libarchive.c
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@redhat.com>2024-10-23 21:48:21 +0200
committerTomas Bzatek <tbzatek@redhat.com>2024-10-23 21:48:21 +0200
commita2dad2d17101658d52d7bd13e2e84fbd1da3e74d (patch)
treed8539bddea035dc43d9031aa232656122e229b91 /libarchive/libarchive.c
parent50352a904b43023985d3c24214fd811ef3ce9a2d (diff)
downloadtuxcmd-modules-0.6.81.tar.xz
libarchive: Port to TUXCMD_ERRORv0.6.81
Mostly the copy operation is now translated.
Diffstat (limited to 'libarchive/libarchive.c')
-rw-r--r--libarchive/libarchive.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/libarchive/libarchive.c b/libarchive/libarchive.c
index 1e4f984..13789e1 100644
--- a/libarchive/libarchive.c
+++ b/libarchive/libarchive.c
@@ -38,6 +38,7 @@
#include "logutils.h"
#include "filelist.h"
#include "filelist-vfs-intf.h"
+#include "tuxcmd-error.h"
#include <archive.h>
#include <archive_entry.h>
@@ -47,8 +48,8 @@
#endif
-#define MODULE_VERSION "0.3.1"
-#define MODULE_BUILD_DATE "2024-01-19"
+#define MODULE_VERSION "0.3.2"
+#define MODULE_BUILD_DATE "2024-10-23"
#define DEFAULT_BLOCK_SIZE 65536
@@ -691,8 +692,8 @@ my_archive_read_data_into_fd (struct TVFSGlobs *globs, struct archive *a, struct
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (fd < 0) {
saved_errno = errno;
- log_error ("my_archive_read_data_into_fd: error occured while extracting data: %s", strerror (saved_errno));
- g_set_error (error, G_IO_ERROR, g_io_error_from_errno (saved_errno), "Error extracting data: %s", g_strerror (saved_errno));
+ log_error ("my_archive_read_data_into_fd: error opening dest file '%s': %s", sDstName, strerror (saved_errno));
+ g_set_error (error, TUXCMD_ERROR, TUXCMD_ERROR_TARGET_OPEN, "%s", g_strerror (saved_errno));
return FALSE;
}
@@ -715,8 +716,8 @@ my_archive_read_data_into_fd (struct TVFSGlobs *globs, struct archive *a, struct
bytes_written = write (fd, p, bytes_to_write);
if (bytes_written < 0) {
saved_errno = errno;
- log_error ("my_archive_read_data_into_fd: error occured while extracting data: %s", strerror (saved_errno));
- g_set_error (error, G_IO_ERROR, g_io_error_from_errno (saved_errno), "Error writing data: %s", g_strerror (saved_errno));
+ log_error ("my_archive_read_data_into_fd: error occured while writing data: %s", strerror (saved_errno));
+ g_set_error (error, TUXCMD_ERROR, TUXCMD_ERROR_TARGET_WRITE, "%s", g_strerror (saved_errno));
close (fd);
return FALSE;
}
@@ -737,20 +738,20 @@ my_archive_read_data_into_fd (struct TVFSGlobs *globs, struct archive *a, struct
/* FIXME: shall we treat ARCHIVE_EOF as an error? */
if (r != ARCHIVE_OK && r != ARCHIVE_EOF) {
log_error ("my_archive_read_data_into_fd: error reading archive: %s", archive_error_string (a));
- g_set_error_literal (error, G_IO_ERROR, g_io_error_from_errno (archive_errno (a)), archive_error_string (a));
+ g_set_error_literal (error, TUXCMD_ERROR, TUXCMD_ERROR_SOURCE_READ, archive_error_string (a));
close (fd);
return FALSE;
}
if (close (fd)) {
saved_errno = errno;
log_error ("my_archive_read_data_into_fd: error closing extracted file: %m");
- g_set_error (error, G_IO_ERROR, g_io_error_from_errno (saved_errno), "Error closing extracted file: %s", g_strerror (saved_errno));
+ g_set_error (error, TUXCMD_ERROR, TUXCMD_ERROR_TARGET_CLOSE, "%s", g_strerror (saved_errno));
return FALSE;
}
if (cancel) {
if (unlink (sDstName))
log_error ("my_archive_read_data_into_fd: error unlinking cancelled extraction: %m");
- g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_CANCELLED, "Operation has been cancelled.");
+ g_set_error_literal (error, TUXCMD_ERROR, TUXCMD_ERROR_CANCELLED, "Operation has been cancelled.");
return FALSE;
}
log_debug ("my_archive_read_data_into_fd: done.");
@@ -762,7 +763,7 @@ gboolean
VFSStartCopyOperation (struct TVFSGlobs *globs, GError **error)
{
if (globs->op_archive != NULL) {
- g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_ALREADY_MOUNTED, "globs->op_archive != NULL");
+ g_set_error_literal (error, TUXCMD_ERROR, TUXCMD_ERROR_EXCEPTION, "globs->op_archive != NULL");
return FALSE;
}
@@ -776,7 +777,7 @@ gboolean
VFSStopCopyOperation (struct TVFSGlobs *globs, GError **error)
{
if (globs->op_archive == NULL) {
- g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_ALREADY_MOUNTED, "globs->op_archive == NULL");
+ g_set_error_literal (error, TUXCMD_ERROR, TUXCMD_ERROR_EXCEPTION, "globs->op_archive == NULL");
return FALSE;
}
@@ -802,12 +803,12 @@ VFSCopyToLocal (struct TVFSGlobs *globs, const char *sSrcName, const char *sDstN
if (globs->op_archive == NULL) {
- g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, "globs->op_archive == NULL");
+ g_set_error_literal (error, TUXCMD_ERROR, TUXCMD_ERROR_EXCEPTION, "globs->op_archive == NULL");
return FALSE;
}
if (sSrcName == NULL || sDstName == NULL || strlen (sSrcName) < 1 || strlen (sDstName) < 1) {
log_error ("VFSCopyToLocal: The value of 'sSrcName' or 'sDstName' is NULL or empty");
- g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT, "The value of 'sSrcName' or 'sDstName' is NULL or empty.");
+ g_set_error_literal (error, TUXCMD_ERROR, TUXCMD_ERROR_EXCEPTION, "The value of 'sSrcName' or 'sDstName' is NULL or empty.");
return FALSE;
}
@@ -816,7 +817,7 @@ VFSCopyToLocal (struct TVFSGlobs *globs, const char *sSrcName, const char *sDstN
node = filelist_tree_find_node_by_path (globs->files, sSrcName);
if (! node) {
log_error ("VFSCopyToLocal: cannot find file '%s'", sSrcName);
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, "cannot find file '%s'", sSrcName);
+ g_set_error (error, TUXCMD_ERROR, TUXCMD_ERROR_SOURCE_OPEN, "Cannot find file '%s'", sSrcName);
return FALSE;
}
@@ -842,7 +843,7 @@ VFSCopyToLocal (struct TVFSGlobs *globs, const char *sSrcName, const char *sDstN
} else
if (r != ARCHIVE_OK) {
log_error ("VFSCopyToLocal: error occured while reading archive: '%s'", archive_error_string (globs->op_archive));
- g_set_error_literal (error, G_IO_ERROR, g_io_error_from_errno (archive_errno (globs->op_archive)), archive_error_string (globs->op_archive));
+ g_set_error_literal (error, TUXCMD_ERROR, TUXCMD_ERROR_SOURCE_READ, archive_error_string (globs->op_archive));
break;
}
@@ -856,7 +857,7 @@ VFSCopyToLocal (struct TVFSGlobs *globs, const char *sSrcName, const char *sDstN
if (! found && res) {
log_error ("VFSCopyToLocal: file not found in the archive.");
if (error && *error == NULL)
- g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, "File not found in the archive.");
+ g_set_error_literal (error, TUXCMD_ERROR, TUXCMD_ERROR_SOURCE_OPEN, "File not found in the archive.");
res = FALSE;
}
@@ -868,8 +869,8 @@ VFSCopyToLocal (struct TVFSGlobs *globs, const char *sSrcName, const char *sDstN
gboolean
VFSCopyFromLocal (struct TVFSGlobs *globs, const char *sSrcName, const char *sDstName, gboolean Append, GError **error)
{
- log_debug ("VFSCopyFromLocal: Not supported in libarchive plugin.");
- g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, "Not supported in libarchive plugin.");
+ log_debug ("VFSCopyFromLocal: Not supported by the libarchive plugin.");
+ g_set_error_literal (error, TUXCMD_ERROR, TUXCMD_ERROR_NOT_SUPPORTED, "Not supported by the libarchive plugin.");
return FALSE;
}