| 1747 | } |
| 1748 | |
| 1749 | static void remove_maybe_stale_table(struct reftable_stack *st, uint64_t max, |
| 1750 | const char *name) |
| 1751 | { |
| 1752 | int err = 0; |
| 1753 | uint64_t update_idx = 0; |
| 1754 | struct reftable_block_source src = { NULL }; |
| 1755 | struct reftable_table *table = NULL; |
| 1756 | struct reftable_buf table_path = REFTABLE_BUF_INIT; |
| 1757 | |
| 1758 | err = stack_filename(&table_path, st, name); |
| 1759 | if (err < 0) |
| 1760 | goto done; |
| 1761 | |
| 1762 | err = reftable_block_source_from_file(&src, table_path.buf); |
| 1763 | if (err < 0) |
| 1764 | goto done; |
| 1765 | |
| 1766 | err = reftable_table_new(&table, &src, name); |
| 1767 | if (err < 0) |
| 1768 | goto done; |
| 1769 | |
| 1770 | update_idx = reftable_table_max_update_index(table); |
| 1771 | reftable_table_decref(table); |
| 1772 | |
| 1773 | if (update_idx <= max) { |
| 1774 | unlink(table_path.buf); |
| 1775 | } |
| 1776 | done: |
| 1777 | reftable_buf_release(&table_path); |
| 1778 | } |
| 1779 | |
| 1780 | static int reftable_stack_clean_locked(struct reftable_stack *st) |
| 1781 | { |
no test coverage detected