2019-01-24 16:43:03 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2021-02-22 16:14:39 +08:00
|
|
|
|
using osu.Framework.IO.Network;
|
2017-09-09 04:23:42 +08:00
|
|
|
|
using osu.Game.Beatmaps;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-09-09 01:07:28 +08:00
|
|
|
|
namespace osu.Game.Online.API.Requests
|
|
|
|
|
{
|
2021-11-05 16:37:05 +08:00
|
|
|
|
public class DownloadBeatmapSetRequest : ArchiveDownloadRequest<IBeatmapSetInfo>
|
2017-09-09 01:07:28 +08:00
|
|
|
|
{
|
2017-11-05 19:03:58 +08:00
|
|
|
|
private readonly bool noVideo;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-11-05 16:37:05 +08:00
|
|
|
|
public DownloadBeatmapSetRequest(IBeatmapSetInfo set, bool noVideo)
|
2019-06-11 22:06:08 +08:00
|
|
|
|
: base(set)
|
2017-09-09 01:07:28 +08:00
|
|
|
|
{
|
2017-11-05 19:03:58 +08:00
|
|
|
|
this.noVideo = noVideo;
|
2017-09-09 01:07:28 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-02-22 16:14:39 +08:00
|
|
|
|
protected override WebRequest CreateWebRequest()
|
|
|
|
|
{
|
|
|
|
|
var req = base.CreateWebRequest();
|
|
|
|
|
req.Timeout = 60000;
|
|
|
|
|
return req;
|
|
|
|
|
}
|
|
|
|
|
|
Fix temp files from beatmap listing imports not being cleaned up
As reported in #12718, it turns out that temporary files from beatmap
set downloads performed via the beatmap listing overlay could remain in
the user's filesystem even after the download has concluded.
The reason for the issue is a failure in component integration.
In the case of online downloads, files are first downloaded to a
temporary directory (`C:/Temp` or `/tmp`), with a randomly generated
filename, which ends in an extension of `.tmp`.
On the other side, `ArchiveModelManager`s have a `ShouldDeleteArchive()`
method, which determines whether a file should be deleted after
importing. At the time of writing, in the case of beatmap imports the
file is only automatically cleaned up if the extension of the file is
equal to `.osz`, which was not the case for temporary files.
As it turns out, `APIDownloadRequest` has a facility for adjusting the
file's extension, via the protected `FileExtension` property. Therefore,
use it in the case of `DownloadBeatmapSetRequest` to specify `.osz`,
which then will make sure that the `ShouldDeleteArchive()` check in
`BeatmapManager` picks it up for clean-up.
2021-05-08 22:30:08 +08:00
|
|
|
|
protected override string FileExtension => ".osz";
|
|
|
|
|
|
2021-11-05 16:37:05 +08:00
|
|
|
|
protected override string Target => $@"beatmapsets/{Model.OnlineID}/download{(noVideo ? "?noVideo=1" : "")}";
|
2017-09-09 01:07:28 +08:00
|
|
|
|
}
|
|
|
|
|
}
|