Commit Diff
- Commit:
06285208fae857821ae1f92a774f2bc91c71ec7a9f5817693caf26bb5f88fad7- From:
- Stefan Sperling <stsp@stsp.name>
- Date:
- Message:
- cleanup: fix redundant pack file removal when repository contains symlinks Add symlinks to the set of traversed object IDs during cleanup. Otherwise, packfiles which contain blobs that are symlinks will always be marked as containing unreferenced objects and 'gotadmin cleanup' will not remove them. This can result in an explosion of redundant packfiles if 'gotadmin cleanup' is run at regular intervals, and if the cleanup -a option is not used. I am unsure how to write a test case for this fix without making additional changes to the cleanup command. The tests run cleanup -a to bypass the mtime staleness safety check. This will never hit the problematic case fixed here. Reproducing the problem would require a test which waits for the (currently) hard-coded interval of 600 seconds before running cleanup. If we added a way to tweak the mtime threshold from tests then we could probably add a test case which covers this issue. Problem found because gothub.org backups were taking much more disk space than expected. ok runxi yu, op@
- Actions:
- Patch | Tree
--- lib/repository_admin.c +++ lib/repository_admin.c @@ -865,8 +865,7 @@ load_tree_entries(struct got_object_id_queue *ids, break; } - if (got_object_tree_entry_is_symlink(e) || - got_object_tree_entry_is_submodule(e) || + if (got_object_tree_entry_is_submodule(e) || got_object_idset_contains(traversed_ids, id)) continue; @@ -882,7 +881,7 @@ load_tree_entries(struct got_object_id_queue *ids, if (err) break; STAILQ_INSERT_TAIL(ids, qid, entry); - } else if (S_ISREG(mode)) { + } else if (S_ISREG(mode) || S_ISLNK(mode)) { /* This blob is referenced. */ err = got_object_idset_add(traversed_ids, id, NULL); if (err)
