* Write errors (particularly out of space) can result in * failed temporary packs (and more rarely indexes and other * files beginning with "tmp_") accumulating in the object * and the pack directories. */
| 133 | * and the pack directories. |
| 134 | */ |
| 135 | static void remove_temporary_files(const char *path) |
| 136 | { |
| 137 | DIR *dir; |
| 138 | struct dirent *de; |
| 139 | |
| 140 | dir = opendir(path); |
| 141 | if (!dir) { |
| 142 | if (errno != ENOENT) |
| 143 | fprintf(stderr, "Unable to open directory %s: %s\n", |
| 144 | path, strerror(errno)); |
| 145 | return; |
| 146 | } |
| 147 | while ((de = readdir(dir)) != NULL) |
| 148 | if (starts_with(de->d_name, "tmp_")) |
| 149 | prune_tmp_file(mkpath("%s/%s", path, de->d_name)); |
| 150 | closedir(dir); |
| 151 | } |
| 152 | |
| 153 | int cmd_prune(int argc, |
| 154 | const char **argv, |
no test coverage detected