{"action":"created","issue":{"url":"https://api.github.com/repos/github/git-lfs/issues/290","labels_url":"https://api.github.com/repos/github/git-lfs/issues/290/labels{/name}","comments_url":"https://api.github.com/repos/github/git-lfs/issues/290/comments","events_url":"https://api.github.com/repos/github/git-lfs/issues/290/events","html_url":"https://github.com/github/git-lfs/pull/290","id":74430184,"number":290,"title":"Fsck command","user":{"login":"technoweenie","id":21,"avatar_url":"https://avatars.githubusercontent.com/u/21?v=3","gravatar_id":"","url":"https://api.github.com/users/technoweenie","html_url":"https://github.com/technoweenie","followers_url":"https://api.github.com/users/technoweenie/followers","following_url":"https://api.github.com/users/technoweenie/following{/other_user}","gists_url":"https://api.github.com/users/technoweenie/gists{/gist_id}","starred_url":"https://api.github.com/users/technoweenie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/technoweenie/subscriptions","organizations_url":"https://api.github.com/users/technoweenie/orgs","repos_url":"https://api.github.com/users/technoweenie/repos","events_url":"https://api.github.com/users/technoweenie/events{/privacy}","received_events_url":"https://api.github.com/users/technoweenie/received_events","type":"User","site_admin":true},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-08T17:08:19Z","updated_at":"2015-05-09T04:16:56Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/github/git-lfs/pulls/290","html_url":"https://github.com/github/git-lfs/pull/290","diff_url":"https://github.com/github/git-lfs/pull/290.diff","patch_url":"https://github.com/github/git-lfs/pull/290.patch"},"body":"This builds on #280 by @zeroshirts, adding an fsck command.  Right now, all it does is makes sure the `.git/lfs/objects` files all match the OID (a sha256 hash of the contents).  By default, it removes any bad files so that Git LFS can re-download them the next time they're referenced.\r\n\r\nQuestions:\r\n\r\nIs `fsck` the right name?  It would be cool to eventually have something like Homebrew's `doctor` command for checking multiple things besides file system stuff.\r\n\r\nIs deleting the corrupt objects the right default?  I'm not sure what we could do to fix files.\r\n\r\nObservations (not necessarily blockers for this PR):\r\n\r\nWe should think hard about how `git fsck` decides what Git refs to scan.  It currently only looks in HEAD and the index.  Though I can come up with other useful scenarios:\r\n\r\n* Scan a commit by name: `git lfs fsck --commit abcdef`\r\n* Scan everything in `.git/lfs/objects`: `git lfs fsck --all`\r\n* Scan all commits.\r\n\r\nIt'd also be nice if there was some consistency in how options work with `git lfs fsck` and potentially similar commands like `git lfs get`.\r\n\r\nAlso, we may want to build a higher level scanner in the `lfs` package, instead of calling `lfs.ScanRefs()` and `lfs.ScanIndex()` directly.  Something that we can re-use in other commands, without having to export internal things like `*lfs.wrappedPointer`.\r\n\r\n```golang\r\ncfg := &lfs.ScanConfig{\r\n  StartCommit: \"abcdef\",\r\n  EndCommit: \"ghijkl\",\r\n}\r\n\r\nerr := lfs.Scan(cfg, func(path string, p *lfs.Pointer) error {\r\n  ...\r\n})\r\n```"},"comment":{"url":"https://api.github.com/repos/github/git-lfs/issues/comments/100422795","html_url":"https://github.com/github/git-lfs/pull/290#issuecomment-100422795","issue_url":"https://api.github.com/repos/github/git-lfs/issues/290","id":100422795,"user":{"login":"zeroshirts","id":1655014,"avatar_url":"https://avatars.githubusercontent.com/u/1655014?v=3","gravatar_id":"","url":"https://api.github.com/users/zeroshirts","html_url":"https://github.com/zeroshirts","followers_url":"https://api.github.com/users/zeroshirts/followers","following_url":"https://api.github.com/users/zeroshirts/following{/other_user}","gists_url":"https://api.github.com/users/zeroshirts/gists{/gist_id}","starred_url":"https://api.github.com/users/zeroshirts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zeroshirts/subscriptions","organizations_url":"https://api.github.com/users/zeroshirts/orgs","repos_url":"https://api.github.com/users/zeroshirts/repos","events_url":"https://api.github.com/users/zeroshirts/events{/privacy}","received_events_url":"https://api.github.com/users/zeroshirts/received_events","type":"User","site_admin":false},"created_at":"2015-05-09T04:16:56Z","updated_at":"2015-05-09T04:16:56Z","body":"Good catch finding the part where I leaked a file descriptor on that error return path ( https://github.com/github/git-lfs/commit/2f6c3beba36f5c67026339b1972814b043a1e5bf ).  The only problem with using the defer f.Close() trick is that you'll hold to all of the file descriptors in that for loop and then close them all at once on function exit.  Imagine if a user has thousands of tracked LFS files... we could potentially exhaust the pool of available file descriptors.  I suggest closing them as 'early' as possible to avoid this."}}