View rollback: version files and column directories aren't deleted

anymore to prevent indexer bug, and fixed a freeing bug
This commit is contained in:
Celine Mercier
2017-11-15 17:27:26 +01:00
parent 9a50803c00
commit 3ba7ce1c91
2 changed files with 33 additions and 29 deletions

View File

@ -957,6 +957,11 @@ OBIDMS_column_p obi_create_column(OBIDMS_p dms,
return NULL;
}
if (strcmp(column_name, "merged") == 0)
{
fprintf(stderr, "\nversion nb = %d\n", version_number);
}
// Build the indexer name if needed
if ((data_type == OBI_STR) || (data_type == OBI_SEQ) || (data_type == OBI_QUAL) || tuples)
{
@ -1997,10 +2002,10 @@ int obi_clean_unfinished_columns(OBIDMS_p dms)
char* column_dir_path;
char* col_name;
char* col_version_str;
char* version_file;
// char* version_file;
obiversion_t col_version;
OBIDMS_column_header_p col_header;
int n;
// int n;
char* col_to_delete[1000];
char* dir_to_delete[1000];
int ddir;
@ -2124,27 +2129,28 @@ int obi_clean_unfinished_columns(OBIDMS_p dms)
}
// Add column dir in list to delete if it's empty
n = count_dir(column_dir_path);
if (n == 1) // Only file left is the version file
{
// Delete the version file
version_file = obi_version_file_full_path(dms, col_name);
if (version_file == NULL)
{
obidebug(1, "\nError getting a version file path when deleting unfinished columns");
ret_value = -1;
continue;
}
if (remove(version_file) < 0)
{
obi_set_errno(OBICOL_UNKNOWN_ERROR);
obidebug(1, "\nError deleting a version file when deleting unfinished columns: file %s", version_file);
ret_value = -1;
}
free(version_file);
dir_to_delete[ddir] = column_dir_path;
ddir++;
}
// TODO commented because causes bug when cloning AVL using column version for name. to discuss
// n = count_dir(column_dir_path);
// if (n == 1) // Only file left is the version file
// {
// // Delete the version file
// version_file = obi_version_file_full_path(dms, col_name);
// if (version_file == NULL)
// {
// obidebug(1, "\nError getting a version file path when deleting unfinished columns");
// ret_value = -1;
// continue;
// }
// if (remove(version_file) < 0)
// {
// obi_set_errno(OBICOL_UNKNOWN_ERROR);
// obidebug(1, "\nError deleting a version file when deleting unfinished columns: file %s", version_file);
// ret_value = -1;
// }
// free(version_file);
// dir_to_delete[ddir] = column_dir_path;
// ddir++;
// }
free(col_name);
}

View File

@ -2671,7 +2671,7 @@ int obi_rollback_view(Obiview_p view)
ret_value = -1;
}
// Delete column dir if it's empty
// Delete column dir if it's empty TODO doesn't happen because version file
n = count_dir(column_dir_path);
if (n == 0)
{
@ -2687,7 +2687,6 @@ int obi_rollback_view(Obiview_p view)
free(column_dir_path);
}
}
// Delete line selection if there is one
if (view->line_selection != NULL)
{
@ -2726,7 +2725,7 @@ int obi_rollback_view(Obiview_p view)
ret_value = -1;
}
// Delete column dir if it's empty
// Delete column dir if it's empty TODO doesn't happen because version file
n = count_dir(column_dir_path);
if (n == 0)
{
@ -2767,11 +2766,11 @@ int obi_rollback_view(Obiview_p view)
strcat(view_relative_path, view_file_name);
view_full_path = obi_dms_get_full_path(view->dms, view_relative_path);
remove(view_full_path);
free(view_relative_path);
free(view_full_path);
}
}
free(view_file_name);
free(view_relative_path);
free(view_full_path);
}
// Free the linked list of column pointers
@ -2779,7 +2778,6 @@ int obi_rollback_view(Obiview_p view)
// Free the column dictionary
ht_free(view->column_dict);
free(view);
return ret_value;