1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-15 01:57:51 +08:00
Commit Graph

273 Commits

Author SHA1 Message Date
Salman Ahmed
e8a6381395 Update naming of enum fields in ObjType 2024-05-01 17:24:53 +03:00
Dean Herbert
c8f7f2215b
Force encoding to Shift-JIS for archive filenames
After way too much time investigating this, the encoding situation is
not great right now.

- Stable sets the "default code page" to be used for encoding filenames
to Shift-JIS (932):
c29ebd7fc5/osu!/GameBase.cs#L3099
- Lazer does nothing (therefore using UTF-8).

When importing to lazer, stable files are assumed to be UTF-8. This
means that the linked beatmaps don't work correctly. Forcing lazer to
decompress *and* compress using Shift-JIS will fix this.

Here's a rough idea of how things look for japanese character filenames
in current `master`:

| | stable | lazer |
|--------|--------|--------|
| export encoding | shift-jis | utf8 |
| utf8 [bit flag](https://superuser.com/a/1507988) set |  |  |
| import stable export osz |   |  |
| import lazer export osz |  |  |
| windows unzip |  |  |
| macos unzip |  |  |

and after this change

| | stable | lazer |
|--------|--------|--------|
| export encoding | shift-jis | shift-jis |
| utf8 [bit flag](https://superuser.com/a/1507988) set |  |  |
| import stable export osz |   |  |
| import lazer export osz |  |  |
| windows unzip |  |  |
| macos unzip |  |  |

A future endeavour to improve compatibility would be to look at setting
the utf8 flag in lazer, switching the default to utf8, and ensuring the
stable supports this flag (I don't believe it does right now).
2024-04-30 01:27:47 +08:00
Bartłomiej Dach
83e47b3c4c
Fix exports containing zero byte files after import from specific ZIP archives
Closes https://github.com/ppy/osu/issues/27540.

As it turns out, some ZIP archivers (like 7zip) will decide to add fake
entries for directories, and some (like windows zipfolders) won't.
The "directory" entries aren't really properly supported using any
actual data or attributes, they're detected by sharpcompress basically
by heuristics:

    ab5535eba3/src/SharpCompress/Common/Zip/Headers/ZipFileEntry.cs (L19-L31)

When importing into realm we have thus far presumed that these directory
entries will not be a thing. Having them be a thing breaks multiple
things, like:

- When importing from ZIPs with separate directory entries, a separate
  `RealmFile` is created for a directory entry even though it doesn't
  represent a real file
- As a result, when re-exporting a model with files imported from such
  an archive, a zero-byte file would be created because to the database
  it looks like it was originally a zero-byte file.

If you want to have fun, google "zip empty directories". You'll see
a whole gamut of languages, libraries, and developers stepping on this
rake. Yet another episode of underspecced mistakes from decades ago
that were somebody's "good idea" but continue to wreak havoc forevermore
because now there are two competing conventions you can't just pick one.
2024-03-12 09:06:24 +01:00
Bartłomiej Dach
3d8fdc52a4
Merge pull request #27501 from turbedi/throw_helper
Use ThrowHelper methods in more places
2024-03-07 11:36:21 +01:00
Dean Herbert
b53b752e54
Update usage of MathUtils 2024-03-06 12:13:12 +08:00
Berkan Diler
5965db4fd7 Use ArgumentException.ThrowIfNullOrEmpty throw helper 2024-03-05 10:20:57 +01:00
Dan Balasescu
c8b4ff2b47
Fix compile error (reserved name) 2024-02-02 21:28:51 +09:00
Dan Balasescu
b44f77cee1
Update R# + fix inspections 2024-02-02 21:00:28 +09:00
Dean Herbert
d2990170d0
Add retry loop to avoid log export failing occasionally on windows
Closes https://github.com/ppy/osu/issues/26693.
2024-01-25 13:53:36 +09:00
Dean Herbert
e081fa48a2
Fix various other inspections 2023-10-17 17:48:51 +09:00
Bartłomiej Dach
e57d7d1205
Fix MemoryStreamArchiveReader.GetStream() failing in some cases
`MemoryStreamArchiveReader` introduced in
0657b55196 would previously use
`MemoryStream.GetBuffer()` to retrieve the underlying byte buffer with
stream data. However, this is not generally the method you would want,
for two reasons:

1. It can fail if the stream wasn't created in the way that supports it.
2. As per

	https://learn.microsoft.com/en-us/dotnet/api/system.io.memorystream.getbuffer?view=net-7.0#system-io-memorystream-getbuffer,

   it will return the _raw_ contents of the buffer, including
   potentially unused bytes.

To fix, use `MemoryStream.ToArray()` instead, which avoids both
pitfalls. Notably, `ToArray()` always returns the full contents of the
buffer, regardless of `Position`, as documented in:

    https://learn.microsoft.com/en-us/dotnet/api/system.io.memorystream.toarray?view=net-7.0#system-io-memorystream-toarray
2023-09-18 11:50:36 +02:00
Dean Herbert
541cd972e1 Rename ArchiveReader implementations to read better 2023-09-14 13:36:07 +09:00
Dean Herbert
0657b55196 Avoid MemoryStream.ToArray overhead in LegacyByteArrayReader 2023-09-14 13:33:25 +09:00
Dean Herbert
5e0b89a1a8 Rename GetPath to GetFullPath to better match expectations 2023-08-18 17:56:43 +09:00
Krzysztof Gutkowski
59abb59ee8 Set correct date added value when importing stable beatmapsets 2023-08-17 00:49:48 +02:00
Dean Herbert
d39ef48b71 Return null intead of FileNotFoundException on missing file in ZipArchiveReader 2023-08-03 09:01:11 +09:00
Dean Herbert
df5b389629 Manual fixes to reduce warnings to zero 2023-06-24 01:52:53 +09:00
Dean Herbert
0ab0c52ad5 Automated pass 2023-06-24 01:00:03 +09:00
Dean Herbert
0fcf10e10a Also support hard links on macOS 2022-12-29 22:35:13 +08:00
Bartłomiej Dach
74bc5d4666
Disable naming rule inspection on struct stat definition 2022-12-28 22:38:42 +01:00
Bartłomiej Dach
49b0ec9ddb
Fix broken condition 2022-12-28 22:24:18 +01:00
Bartłomiej Dach
8d79fa93ac
Implement GetFileLinkCount() for Linux 2022-12-28 22:14:56 +01:00
Bartłomiej Dach
04d4b4a6ce
Rename and xmldoc hard link creation method 2022-12-28 22:04:05 +01:00
Bartłomiej Dach
cadd487c75
Use switch statement in AttemptHardLink() 2022-12-28 21:20:49 +01:00
BlauFx
53bca947d1 Move duplicated code into its own method 2022-12-28 14:34:27 +01:00
BlauFx
5c5e84f931 Fix formatiing 2022-12-28 14:06:50 +01:00
BlauFx
16165b1f67 Remove blank line 2022-12-28 13:58:52 +01:00
BlauFx
b2aa2e1602 Add hardlink support for Linux 2022-12-28 13:32:49 +01:00
Berkan Diler
08d2fbeb8e Use new ArgumentNullException.ThrowIfNull throw-helper API 2022-12-22 21:27:59 +01:00
Dean Herbert
192536643c Fix some more inspections 2022-12-16 20:21:19 +09:00
Dean Herbert
a3c3112f89
Add SetLastError hint to CreateHardLink pinvoke method
Co-authored-by: Bartłomiej Dach <dach.bartlomiej@gmail.com>
2022-12-14 11:34:06 +09:00
Dean Herbert
6bb612ce69 Move hard link availability check to helper class 2022-12-13 20:20:42 +09:00
Dean Herbert
bbf931c746 Move hard link helper functions to their own class 2022-12-13 19:55:18 +09:00
Dean Herbert
a8dee17513 Fix missing DummyRenderer in skin resources tests 2022-08-08 13:06:01 +09:00
Dan Balasescu
c4b9b2a14b Merge branch 'master' into irenderer-glwrapper 2022-08-05 20:35:06 +09:00
Dean Herbert
f743dc623f Change migration logic to ignore realm pipe files regardless of database filename 2022-08-03 17:37:30 +09:00
Dan Balasescu
b4e55f7309 Apply IRenderer changes 2022-08-02 19:50:57 +09:00
Dean Herbert
cc8a71b65d Re-query file existence before failing a recursive copy operation during migration 2022-08-01 17:01:19 +09:00
Dean Herbert
59210ecc9d Revert "Fix migration failing on single file copy failure"
This reverts commit fc8835d43a.
2022-08-01 16:57:50 +09:00
Dean Herbert
fc8835d43a Fix migration failing on single file copy failure
No longer throw if copying of single files fails during data migration.

Aiming to fix https://github.com/ppy/osu/runs/7601653833?check_suite_focus=true, which could also affect end users. I've left a limit before an exception is still thrown, to handle cases like the user running out of disk space (where we probably *do* want to bail, so they can continue to use their still-intact original storage location).

If this isn't seen as a good direction, an alternative will be to make the migration code aware of the structure of the temporary files created by `Storage` (but doesn't guarantee this will cover all cases of such temporary files – there could for isntance be metadata files created by the host operating system).

Another option would be to mark those temporary files as hidden and skip any hidden files during iteration.
2022-08-01 15:02:39 +09:00
Bartłomiej Dach
6f37487528
Replace calls to defective Humanizer methods with correct version 2022-07-18 22:34:58 +02:00
Dean Herbert
27ef7fc78e Add log output for custom storage usage
Sometimes I am not sure where my osu! is reading files from. This should
help somewhat.

```csharp
/Users/dean/Projects/osu/osu.Desktop/bin/Debug/net6.0/osu!
[runtime] 2022-07-13 07:22:03 [verbose]: Starting legacy IPC provider...
[runtime] 2022-07-13 07:22:03 [verbose]: Attempting to use custom storage location /Users/dean/Games/osu-lazer-2
[runtime] 2022-07-13 07:22:03 [verbose]: Storage successfully changed to /Users/dean/Games/osu-lazer-2.
[runtime] 2022-07-13 07:22:05 [verbose]: GL Initialized
```
2022-07-13 16:22:51 +09:00
Dean Herbert
66f314915d Fix crash on mobile releases when attempting to read any file 2022-07-09 06:01:22 +09:00
Dean Herbert
c2f1069073 Avoid usage of finally in potentially hot path 2022-07-06 19:55:51 +09:00
Dean Herbert
01bc6e5cb7 Revert old behaviour of ReadToEnd 2022-07-06 19:55:51 +09:00
Dean Herbert
12d396a513 Use -1 to specify default buffer size 2022-07-06 15:43:35 +09:00
Dean Herbert
a52ea3cabe Enable NRT and simplify LineBufferedReader 2022-07-06 14:57:56 +09:00
Dan Balasescu
f8830c6850 Automated #nullable processing 2022-06-17 16:37:17 +09:00
Salman Ahmed
ee8045d507 Add failing test case 2022-06-15 07:33:21 +03:00
Dean Herbert
82a1ba1d46 Use pooled memory for memory copies performed by ZipArchiveReader 2022-05-30 20:22:26 +09:00