Commit 77e2d88e authored by Rob Swindell's avatar Rob Swindell 💬
Browse files

create_archive() will skip directories in supplied file_list

The file_list[] parameter was expected to contain only files, but the directory() function (used to create that file_list[]) returns a list of all directory entries, including sub-directories. I could (and maybe will) add an option to directory() to only include files or dirs, but this seemed the more direct fix for the problem reported by DesotoFireflite (VALHALLA):

TickIT's nodelist_handler.js appears to be creating and leaving behind a sub-directory of the temp directory, triggering this error:
 1/23  11:36:56a  QNET libarchive error -1 (13 opening c:\SBBS\temp\event\nodelist_handler/) creating c:\SBBS\data\VERT.REP 

Why isn't the temp directory fully cleaned up after/between events? That's another thing to look into.
parent 2ac39df7
Pipeline #2617 passed with stage
in 11 minutes and 49 seconds
......@@ -750,6 +750,7 @@ str_list_t directory(const char* path)
const char* supported_archive_formats[] = { "zip", "7z", "tgz", NULL };
// Returns total number of successfully archived files
// Returns negative on error
long create_archive(const char* archive, const char* format
,bool with_path, str_list_t file_list, char* error, size_t maxerrlen)
......@@ -785,10 +786,13 @@ long create_archive(const char* archive, const char* format
return result;
ulong file_count = 0;
ulong archived = 0;
for(;file_list[file_count] != NULL; file_count++) {
struct archive_entry* entry;
struct stat st;
const char* filename = file_list[file_count];
FILE* fp = fopen(filename, "rb");
if(fp == NULL) {
safe_snprintf(error, maxerrlen, "%d opening %s", errno, filename);
......@@ -827,12 +831,13 @@ long create_archive(const char* archive, const char* format
if(result != ARCHIVE_OK)
if(file_list[file_count] != NULL)
return result < 0 ? result : -1;
return file_count;
return archived;
long extract_files_from_archive(const char* archive, const char* outdir, const char* allowed_filename_chars
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment