Merge branch 'master' into editor-selection-tool

This commit is contained in:
Dan Balasescu
2017-12-11 22:24:12 +09:00
committed by GitHub
4 changed files with 77 additions and 38 deletions

77
.vscode/tasks.json vendored
View File

@ -2,63 +2,70 @@
// See https://go.microsoft.com/fwlink/?LinkId=733558 // See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format // for the documentation about the tasks.json format
"version": "2.0.0", "version": "2.0.0",
"command": "msbuild",
"type": "shell",
"suppressTaskName": true,
"args": [
"/property:GenerateFullPaths=true",
"/property:DebugType=portable",
"/verbosity:minimal",
"/m" //parallel compiling support.
],
"tasks": [{ "tasks": [{
"taskName": "Build (Debug)", "label": "Build (Debug)",
"type": "shell",
"command": "msbuild",
"args": [
"/p:GenerateFullPaths=true",
"/p:DebugType=portable",
"/m",
"/v:m"
],
"group": { "group": {
"kind": "build", "kind": "build",
"isDefault": true "isDefault": true
}, },
"problemMatcher": [ "problemMatcher": "$msCompile"
"$msCompile"
]
}, },
{ {
"taskName": "Build (Release)", "label": "Build (Release)",
"type": "shell",
"command": "msbuild",
"args": [
"/p:Configuration=Release",
"/p:DebugType=portable",
"/p:GenerateFullPaths=true",
"/m",
"/v:m"
],
"group": "build", "group": "build",
"args": [ "problemMatcher": "$msCompile"
"/property:Configuration=Release"
],
"problemMatcher": [
"$msCompile"
]
}, },
{ {
"taskName": "Clean (Debug)", "label": "Clean (Debug)",
"type": "shell",
"command": "msbuild",
"args": [ "args": [
"/target:Clean" "/p:DebugType=portable",
"/p:GenerateFullPaths=true",
"/m",
"/t:Clean",
"/v:m"
], ],
"problemMatcher": [ "problemMatcher": "$msCompile"
"$msCompile"
]
}, },
{ {
"taskName": "Clean (Release)", "label": "Clean (Release)",
"type": "shell",
"command": "msbuild",
"args": [ "args": [
"/target:Clean", "/p:Configuration=Release",
"/property:Configuration=Release" "/p:GenerateFullPaths=true",
"/p:DebugType=portable",
"/m",
"/t:Clean",
"/v:m"
], ],
"problemMatcher": [ "problemMatcher": "$msCompile"
"$msCompile"
]
}, },
{ {
"taskName": "Clean All", "label": "Clean All",
"dependsOn": [ "dependsOn": [
"Clean (Debug)", "Clean (Debug)",
"Clean (Release)" "Clean (Release)"
], ],
"problemMatcher": [ "problemMatcher": "$msCompile"
"$msCompile"
]
} }
] ]
} }

View File

@ -535,7 +535,8 @@ namespace osu.Game.Beatmaps
if (existing == null) if (existing == null)
{ {
// TODO: Diff beatmap metadata with set metadata and leave it here if necessary // Exclude beatmap-metadata if it's equal to beatmapset-metadata
if (metadata.Equals(beatmap.Metadata))
beatmap.BeatmapInfo.Metadata = null; beatmap.BeatmapInfo.Metadata = null;
RulesetInfo ruleset = rulesets.GetRuleset(beatmap.BeatmapInfo.RulesetID); RulesetInfo ruleset = rulesets.GetRuleset(beatmap.BeatmapInfo.RulesetID);

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Linq; using System.Linq;
@ -9,7 +10,7 @@ using osu.Game.Users;
namespace osu.Game.Beatmaps namespace osu.Game.Beatmaps
{ {
public class BeatmapMetadata public class BeatmapMetadata : IEquatable<BeatmapMetadata>
{ {
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int ID { get; set; } public int ID { get; set; }
@ -66,5 +67,23 @@ namespace osu.Game.Beatmaps
Source, Source,
Tags Tags
}.Where(s => !string.IsNullOrEmpty(s)).ToArray(); }.Where(s => !string.IsNullOrEmpty(s)).ToArray();
public bool Equals(BeatmapMetadata other)
{
if (other == null)
return false;
return onlineBeatmapSetID == other.onlineBeatmapSetID
&& Title == other.Title
&& TitleUnicode == other.TitleUnicode
&& Artist == other.Artist
&& ArtistUnicode == other.ArtistUnicode
&& AuthorString == other.AuthorString
&& Source == other.Source
&& Tags == other.Tags
&& PreviewTime == other.PreviewTime
&& AudioFile == other.AudioFile
&& BackgroundFile == other.BackgroundFile;
}
} }
} }

View File

@ -32,6 +32,18 @@ namespace osu.Game.Beatmaps
{ {
var context = GetContext(); var context = GetContext();
foreach (var beatmap in beatmapSet.Beatmaps.Where(b => b.Metadata != null))
{
// If we detect a new metadata object it'll be attached to the current context so it can be reused
// to prevent duplicate entries when persisting. To accomplish this we look in the cache (.Local)
// of the corresponding table (.Set<BeatmapMetadata>()) for matching entries to our criteria.
var contextMetadata = context.Set<BeatmapMetadata>().Local.SingleOrDefault(e => e.Equals(beatmap.Metadata));
if (contextMetadata != null)
beatmap.Metadata = contextMetadata;
else
context.BeatmapMetadata.Attach(beatmap.Metadata);
}
context.BeatmapSetInfo.Attach(beatmapSet); context.BeatmapSetInfo.Attach(beatmapSet);
context.SaveChanges(); context.SaveChanges();