Migration problem with lfs repository

Hi,
I have a problem when I try to migrate a repo that has git-lfs.
When migrating with the repository/repoMigrate api route I get a response that everything went fine but it didn’t. (I have the same problem with the web interface).
When I click on an lfs file I get a 500 error.
I analyzed the gitea logs and found out why:

2023/03/15 17:45:16 [6411f575-25] router: slow      POST /api/v1/repos/migrate for [::1]:63010, elapsed 3037.9ms @ repo/migrate.go:36(repo.Migrate)
2023/03/15 17:45:18 ...lfs/content_store.go:58:Put() [E] Whilst putting LFS OID[checksum]: Failed to copy to tmpPath: ch/ec/ksum Error: Content size does not match
2023/03/15 17:45:18 ...s/repository/repo.go:404:1() [E] Repo[52:test/lfs_3]: Error storing content for LFS meta object checksum Content size does not match
2023/03/15 17:45:18 ...s/repository/repo.go:170:MigrateRepositoryGitData() [E] Failed to store missing LFS objects for repository: Content size does not match

I replaced the real checksum with checksum
Gitea tries to copy the file to the temp lfs folder but on the first four characters it puts a / every two characters
So it doesn’t work
Do you have any idea why ?
I’m switching from Ubuntu to a Windows system, could this be the reason ?
I use a local lfs server (the basic one on gitea) in both gitea

That has less to do with gitea, but with how LFS stores the objects. For some undocumented reason LFS storage uses a different directory structure on linux and windows.
Given an example hash of an LFS object of AABBCCDDEEFF...

  • On Linux it is stored as <LFSRootDir>/objects/AA/BB/CCDDEEFF...
  • On Windows it is stored as <LFSRootDir>/objects/AA/BB/AABBCCDDEEFF...

so in order to migrate from windows to linux you need to remove the first 4 characters of each object file.
Or in the other direction append the 4 characters in the directory structure to the file.
I’ve done this is in the past using a simple python script, but I no longer have it, but this is very easy to recreate.