Skip to content

Conversation

@yorunoken
Copy link

@yorunoken yorunoken commented Dec 8, 2025

Solves an issue where users can't import data from a different osu!lazer install. As discussed in #35547, there is currently no way to do this.

The new importer:

  • Reads the source client.realm
  • Copies data from the source realm to current realm
  • Copies over files/ folder from source folder to current folder

This takes a few minutes depending on the size of the old install, and the speed of the disk.

2025-12-08.18-49-07.mp4

Comment on lines 117 to 121
using (var src = new FileStream(sourceFilePath, FileMode.Open, FileAccess.Read))
using (var dst = destFilesStorage.CreateFileSafely(relativePath))
{
await src.CopyToAsync(dst).ConfigureAwait(false);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably want to use RealmFileStore.Add here. It has better safeties when the destination already exists, and also allows making use of hard link support when available.

Copy link
Author

@yorunoken yorunoken Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay! I removed my own check for the file existing and also removed importRealmFiles since RealmFileStore.Add already adds the file's hash to the database.
One issue I came across is that the game tries to create the hard-link, but doesn't end up doing so. Both of the folders are in the same partition and using ext4. Is it because I'm using FileStream? Tried to debug for a bit but couldn't end up solving it.

using (var data = File.OpenRead(sourceFilePath))
{
    realmFileStore.Add(data, destRealm, preferHardLinks: true); // Logs `Attempting to create hard-link.` (temporarliy modified the code to tell me if it's trying to create a hard link)
}
$ stat ~/osu-lazer/osu-lazer/files/a/a1/a1556d0801b3a6b175dda32ef546f0ec812b400499f575c44fccbe9c67f9b1e5
  File: /home/yorunoken/osu-lazer/osu-lazer/files/a/a1/a1556d0801b3a6b175dda32ef546f0ec812b400499f575c44fccbe9c67f9b1e5
  Size: 988             Blocks: 8          IO Block: 4096   regular file
Device: 8,2     Inode: 41419647    Links: 1 <-- supposed to be `2`
Access: (0644/-rw-r--r--)  Uid: ( 1000/yorunoken)   Gid: ( 1000/yorunoken)
Access: 2025-12-09 16:20:02.611529150 +0300
Modify: 2025-12-09 16:20:02.561773813 +0300
Change: 2025-12-09 16:20:02.562294539 +0300
 Birth: 2025-12-09 16:20:02.561773813 +0300

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah this is a really weird one. Until now we've been working with FileStreams returned from ArchiveReader that seem to set the stream.Name to the full path (which is then consumed here. Can you check what you're seeing in the Name property of the stream in this case?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, the issue was that sourceFilePath was a relative path, not absolute. I've fixed that now

@peppy
Copy link
Member

peppy commented Dec 9, 2025

This is a bit of a niche one, but also very cool that it can be done quite simply (and very isolated). I'm not against having this as a feature.

@peppy peppy added the area:import dealing with importing of data from stable or file formats label Dec 9, 2025
@Theighlin
Copy link

Theighlin commented Dec 9, 2025

There's 2 things that i think should be improved.

  • Mimic the first run setup import page, allowing the user to choose what to import (toggles for the 4 categories)
  • An option to delete the other installation as it imports or after it's done, or a footnote about how this doesn't delete the other install, so the user knows they have to do it themselves.

Also, since the import notification does not differentiate what is being imported. I'd do away with the notification spam and only use a single "files imported" one. (I think the setup wizard import does differentiate though...?)

@yorunoken
Copy link
Author

I tried to match the UX to the way osu! imports stable hence why the previous install doesn't get deleted. Since the files are hardlinked (where they can) with peppy's fix, it doesn't eat up additional disk space

As for the notifications, they only looked spammy in the video because the test dataset was tiny. On a real install, the steps take actual time, so I think keeping them separate gives more transparency to the user.

I also tidied up the UI so it looks a bit cleaner now:

image

@Theighlin
Copy link

I'm not too fussed about the deleting part, it's a decision for the osu team in the end.
My reasoning was that, in my mind, syncing stable and lazer and syncing two lazer installs are two different things. You might want to use two different clients, but why would you need another lazer install tha has less files than your now synced one?
But i can see now that deleting user files in such a way might be bad UX depending on the use case or system configuration.

@peppy
Copy link
Member

peppy commented Dec 10, 2025

@yorunoken before i dive in and give a full review, can you update the UI components to use the newer "Form" component style? It doesn't make too much sense to add new screens to the game using the old style when we're trying to migrate away.

@yorunoken
Copy link
Author

yorunoken commented Dec 10, 2025

of course, I also followed same design as FileImportScreen since they have similar functionality.

image I kept the menu on the right scrollable, is that needed?

@peppy
Copy link
Member

peppy commented Dec 11, 2025

was also proposing using things like FormButton, fwiw.

@yorunoken
Copy link
Author

I want a way to tell the user how many beatmaps are going to be imported (since it looks good and also how importing from stable works), but it's kind of awkward with the Form components because you can't change Caption or HintText after initialization, that's why I didn't use them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:import dealing with importing of data from stable or file formats size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants