forgejo/modules/repository
Jason Song 2302cf63c8
Distinguish LFS object errors to ignore missing objects during migration (#31702)
Fix #31137.

Replace #31623 #31697.

When migrating LFS objects, if there's any object that failed (like some
objects are losted, which is not really critical), Gitea will stop
migrating LFS immediately but treat the migration as successful.

This PR checks the error according to the [LFS api
doc](https://github.com/git-lfs/git-lfs/blob/main/docs/api/batch.md#successful-responses).

> LFS object error codes should match HTTP status codes where possible:
>
> - 404 - The object does not exist on the server.
> - 409 - The specified hash algorithm disagrees with the server's
acceptable options.
> - 410 - The object was removed by the owner.
> - 422 - Validation error.

If the error is `404`, it's safe to ignore it and continue migration.
Otherwise, stop the migration and mark it as failed to ensure data
integrity of LFS objects.

And maybe we should also ignore others errors (maybe `410`? I'm not sure
what's the difference between "does not exist" and "removed by the
owner".), we can add it later when some users report that they have
failed to migrate LFS because of an error which should be ignored.

(cherry picked from commit 09b56fc0690317891829906d45c1d645794c63d5)
2024-08-04 18:24:10 +02:00
..
branch.go fix(repository): git push to an adopted repository fails 2024-06-16 19:06:06 +02:00
branch_test.go Add testifylint to lint checks (#4535) 2024-07-30 19:41:10 +00:00
collaborator.go [MODERATION] User blocking 2024-02-05 15:56:45 +01:00
collaborator_test.go Add testifylint to lint checks (#4535) 2024-07-30 19:41:10 +00:00
commits.go Fix context cache bug & enable context cache for dashabord commits' authors (#26991) 2023-09-11 10:14:01 +00:00
commits_test.go Add testifylint to lint checks (#4535) 2024-07-30 19:41:10 +00:00
create.go Add merge style fast-forward-only (#28954) 2024-02-14 17:19:19 +01:00
create_test.go Add testifylint to lint checks (#4535) 2024-07-30 19:41:10 +00:00
delete.go Even more db.DefaultContext refactor (#27352) 2023-10-03 10:30:41 +00:00
env.go Move database operations of merging a pull request to post receive hook and add a transaction (#30805) 2024-05-12 20:03:10 +02:00
fork.go Reduce usage of db.DefaultContext (#27073) 2023-09-14 17:09:32 +00:00
hooks.go Always write proc-receive hook for all git versions (#29287) 2024-02-26 22:30:25 +01:00
init.go Move generate from module to service (#29465) 2024-03-06 12:10:44 +08:00
init_test.go
license.go
license_test.go Add testifylint to lint checks (#4535) 2024-07-30 19:41:10 +00:00
main_test.go make writing main test easier (#27270) 2023-09-28 01:38:53 +00:00
push.go fix: hook post-receive for sha256 repos 2024-05-15 16:43:16 +02:00
repo.go Distinguish LFS object errors to ignore missing objects during migration (#31702) 2024-08-04 18:24:10 +02:00
repo_test.go Add testifylint to lint checks (#4535) 2024-07-30 19:41:10 +00:00
temp.go Enable more revive linter rules (#30608) 2024-04-28 15:39:00 +02:00