fix(tree): check now if the tree snapshot already exists

This commit is contained in:
lisk77 2025-09-15 03:24:47 +02:00
parent f19209ba0a
commit e2d026502f

View file

@ -62,6 +62,13 @@ void snapshot_tree(FileInfoBuffer* tree, char* hash) {
mkdir(dir_path, 0755); mkdir(dir_path, 0755);
snprintf(file_path, sizeof(file_path), "%s/%s", dir_path, hash+2); snprintf(file_path, sizeof(file_path), "%s/%s", dir_path, hash+2);
if (access(file_path, F_OK) == 0) {
free(tmp);
file_info_buffer_free(files);
free(root);
return;
}
FILE* fp = fopen(file_path, "wb"); FILE* fp = fopen(file_path, "wb");
if (!fp) { if (!fp) {
perror("ERROR: cannot open path in snapshot_tree!"); perror("ERROR: cannot open path in snapshot_tree!");