# Migration problem with lfs repository

**URL:** <https://forum.gitea.com/t/migration-problem-with-lfs-repository/6876>\
**Category:** Gitea Usages\
**Created:** [March 15, 2023, 5:05pm UTC](https://forum.gitea.com/t/migration-problem-with-lfs-repository/6876 "2023-03-15T17:05:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hello7498](https://avatars.discourse-cdn.com/v4/letter/h/a9adbd/32.png) [@Hello7498](https://forum.gitea.com/u/Hello7498)\
**Post date:** [March 15, 2023, 5:05pm UTC](https://forum.gitea.com/t/migration-problem-with-lfs-repository/6876/1 "2023-03-15T17:05:17Z")

</div>

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:

```auto
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

---

<div class="post-metadata">

**Author:** ![Pampersrocker](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/pampersrocker/32/3547_2.png) [@Pampersrocker](https://forum.gitea.com/u/Pampersrocker)\
**Post date:** [March 22, 2023, 6:39pm UTC](https://forum.gitea.com/t/migration-problem-with-lfs-repository/6876/2 "2023-03-22T18:39:28Z")

</div>

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.
