gitea/modules/repository
Giteabot 6203ae764a
Distinguish LFS object errors to ignore missing objects during migration (#31702) (#31745)
Backport #31702 by @wolfogre

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.

Co-authored-by: Jason Song <i@wolfogre.com>
2024-07-31 23:06:37 +08:00
..
branch.go Fix adopt repository has empty object name in database (#31333) (#31335) 2024-06-12 15:59:54 +00:00
branch_test.go Make "sync branch" also sync object format and add tests (#30878) (#30880) 2024-05-07 08:33:28 +08:00
collaborator.go
collaborator_test.go
commits.go
commits_test.go
create.go
create_test.go
delete.go
env.go Move database operations of merging a pull request to post receive hook and add a transaction (#30805) (#30888) 2024-05-08 14:17:18 +00:00
fork.go
hooks.go
init.go
init_test.go
license.go
license_test.go
main_test.go
push.go
repo.go Distinguish LFS object errors to ignore missing objects during migration (#31702) (#31745) 2024-07-31 23:06:37 +08:00
repo_test.go
temp.go