Skip to content

Commit 09a1bbb

Browse files
committed
Fix small issue where data download for people without account didn't work
1 parent 4f8c6d8 commit 09a1bbb

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

ReplayBrowser/Controllers/AccountController.cs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -119,29 +119,27 @@ [FromQuery] string guid
119119
.Include(a => a.History)
120120
.FirstOrDefaultAsync(a => a.Guid == parsedGuid);
121121

122-
if (user == null)
123-
{
124-
return NotFound("Account is null. This should not happen.");
125-
}
126-
127122
var zipStream = new MemoryStream();
128123
using (var archive = new ZipArchive(zipStream, ZipArchiveMode.Create, true))
129124
{
130-
var historyEntry = archive.CreateEntry("history.json");
131-
using (var entryStream = historyEntry.Open())
125+
if (user != null)
132126
{
133-
await JsonSerializer.SerializeAsync(entryStream, user.History);
134-
}
127+
var historyEntry = archive.CreateEntry("history.json");
128+
using (var entryStream = historyEntry.Open())
129+
{
130+
await JsonSerializer.SerializeAsync(entryStream, user.History);
131+
}
135132

136-
user.History = null;
133+
user.History = null;
137134

138-
var baseEntry = archive.CreateEntry("user.json");
139-
using (var entryStream = baseEntry.Open())
140-
{
141-
await JsonSerializer.SerializeAsync(entryStream, user, new JsonSerializerOptions
135+
var baseEntry = archive.CreateEntry("user.json");
136+
using (var entryStream = baseEntry.Open())
142137
{
143-
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
144-
});
138+
await JsonSerializer.SerializeAsync(entryStream, user, new JsonSerializerOptions
139+
{
140+
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
141+
});
142+
}
145143
}
146144

147145
var replays = await _context.Replays

0 commit comments

Comments
 (0)