1
0
Fork 0
forgejo/modules/lfs
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
..
client.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
client_test.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
content_store.go [GITEA] Drop sha256-simd in favor of stdlib 2024-02-05 16:09:40 +01:00
endpoint.go escape filename when assemble URL (#22850) 2023-02-12 09:31:14 +08:00
endpoint_test.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
filesystem_client.go fix: close file in the Upload func (#30262) 2024-04-07 15:40:31 +02:00
http_client.go Distinguish LFS object errors to ignore missing objects during migration (#31702) 2024-08-04 18:24:10 +02:00
http_client_test.go Add testifylint to lint checks (#4535) 2024-07-30 19:41:10 +00:00
LICENSE Git LFS support v2 (#122) 2016-12-26 09:16:37 +08:00
pointer.go [GITEA] Drop sha256-simd in favor of stdlib 2024-02-05 16:09:40 +01:00
pointer_scanner_gogit.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
pointer_scanner_nogogit.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
pointer_test.go Add testifylint to lint checks (#4535) 2024-07-30 19:41:10 +00:00
shared.go Distinguish LFS object errors to ignore missing objects during migration (#31702) 2024-08-04 18:24:10 +02:00
transferadapter.go Fix #31185 try fix lfs download from bitbucket failed (#31201) 2024-06-16 13:42:59 +02:00
transferadapter_test.go Add testifylint to lint checks (#4535) 2024-07-30 19:41:10 +00:00