File tree 2 files changed +7
-6
lines changed
2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change 2
2
// See the LICENCE file in the repository root for full licence text.
3
3
4
4
using System ;
5
+ using System . Diagnostics ;
5
6
using System . IO ;
6
7
using System . Linq ;
7
8
using osu . Framework . Extensions ;
@@ -98,15 +99,11 @@ public void Cleanup()
98
99
// can potentially be run asynchronously, although we will need to consider operation order for disk deletion vs realm removal.
99
100
realm . Write ( r =>
100
101
{
101
- // TODO: consider using a realm native query to avoid iterating all files (https://github.com/realm/realm-dotnet/issues/2659#issuecomment-927823707)
102
- var files = r . All < RealmFile > ( ) . ToList ( ) ;
103
-
104
- foreach ( var file in files )
102
+ foreach ( var file in r . All < RealmFile > ( ) . Filter ( "Usages.@count = 0" ) )
105
103
{
106
104
totalFiles ++ ;
107
105
108
- if ( file . BacklinksCount > 0 )
109
- continue ;
106
+ Debug . Assert ( file . BacklinksCount == 0 ) ;
110
107
111
108
try
112
109
{
Original file line number Diff line number Diff line change 1
1
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2
2
// See the LICENCE file in the repository root for full licence text.
3
3
4
+ using System . Linq ;
4
5
using osu . Game . IO ;
5
6
using Realms ;
6
7
@@ -11,5 +12,8 @@ public class RealmFile : RealmObject, IFileInfo
11
12
{
12
13
[ PrimaryKey ]
13
14
public string Hash { get ; set ; } = string . Empty ;
15
+
16
+ [ Backlink ( nameof ( RealmNamedFileUsage . File ) ) ]
17
+ public IQueryable < RealmNamedFileUsage > Usages { get ; } = null ! ;
14
18
}
15
19
}
You can’t perform that action at this time.
0 commit comments