| 1778 | } |
| 1779 | |
| 1780 | static int reftable_stack_clean_locked(struct reftable_stack *st) |
| 1781 | { |
| 1782 | uint64_t max = reftable_merged_table_max_update_index( |
| 1783 | reftable_stack_merged_table(st)); |
| 1784 | DIR *dir = opendir(st->reftable_dir); |
| 1785 | struct dirent *d = NULL; |
| 1786 | if (!dir) { |
| 1787 | return REFTABLE_IO_ERROR; |
| 1788 | } |
| 1789 | |
| 1790 | while ((d = readdir(dir))) { |
| 1791 | int found = 0; |
| 1792 | if (!is_table_name(d->d_name)) |
| 1793 | continue; |
| 1794 | |
| 1795 | for (size_t i = 0; !found && i < st->tables_len; i++) |
| 1796 | found = !strcmp(reftable_table_name(st->tables[i]), d->d_name); |
| 1797 | if (found) |
| 1798 | continue; |
| 1799 | |
| 1800 | remove_maybe_stale_table(st, max, d->d_name); |
| 1801 | } |
| 1802 | |
| 1803 | closedir(dir); |
| 1804 | return 0; |
| 1805 | } |
| 1806 | |
| 1807 | int reftable_stack_clean(struct reftable_stack *st) |
| 1808 | { |
no test coverage detected