Failure on slug generation is now properly handled
This commit is contained in:
24
fiche.c
24
fiche.c
@@ -590,6 +590,11 @@ static void *handle_connection(void *args) {
|
|||||||
// with generated slug on disk
|
// with generated slug on disk
|
||||||
generate_slug(&slug, c->settings->slug_len, extra);
|
generate_slug(&slug, c->settings->slug_len, extra);
|
||||||
|
|
||||||
|
// Something went wrong in slug generation, break here
|
||||||
|
if (!slug) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Increment counter for additional letters needed
|
// Increment counter for additional letters needed
|
||||||
++extra;
|
++extra;
|
||||||
|
|
||||||
@@ -611,6 +616,23 @@ static void *handle_connection(void *args) {
|
|||||||
}
|
}
|
||||||
while(create_directory(c->settings->output_dir_path, slug) != 0);
|
while(create_directory(c->settings->output_dir_path, slug) != 0);
|
||||||
|
|
||||||
|
|
||||||
|
// Slug generation failed, we have to finish here
|
||||||
|
if (!slug) {
|
||||||
|
print_error("Couldn't generate a slug!");
|
||||||
|
print_separator();
|
||||||
|
|
||||||
|
close(c->socket);
|
||||||
|
|
||||||
|
// Cleanup
|
||||||
|
free(c);
|
||||||
|
free(slug);
|
||||||
|
pthread_exit(NULL);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Save to file failed, we have to finish here
|
||||||
if ( save_to_file(buffer, c->settings->output_dir_path, slug) != 0 ) {
|
if ( save_to_file(buffer, c->settings->output_dir_path, slug) != 0 ) {
|
||||||
print_error("Couldn't save a file!");
|
print_error("Couldn't save a file!");
|
||||||
print_separator();
|
print_separator();
|
||||||
@@ -671,7 +693,7 @@ static void generate_slug(char **output, uint8_t length, uint8_t extra_length) {
|
|||||||
*output = calloc(length + 1 + extra_length, sizeof(char));
|
*output = calloc(length + 1 + extra_length, sizeof(char));
|
||||||
|
|
||||||
if (*output == NULL) {
|
if (*output == NULL) {
|
||||||
// TODO
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Take n-th symbol from symbol table and use it for slug generation
|
// Take n-th symbol from symbol table and use it for slug generation
|
||||||
|
|||||||
Reference in New Issue
Block a user