summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJake Mannens <jake@asger.xyz>2026-06-19 02:21:16 +1000
committerJake Mannens <jake@asger.xyz>2026-06-19 02:21:16 +1000
commit79d383f6f48df0078e6ba13239f9c4c94fbc9ea6 (patch)
tree4450904ebdc5083a69f544e49478281ebbc2429e
parente556de927015acd8d9934e68707a95901acfad8e (diff)
v0.19av0.19a
-rw-r--r--Server.csproj4
-rw-r--r--Services/MediaService.cs20
-rw-r--r--Util.cs5
3 files changed, 20 insertions, 9 deletions
diff --git a/Server.csproj b/Server.csproj
index 9d60d7d..8de0960 100644
--- a/Server.csproj
+++ b/Server.csproj
@@ -6,9 +6,9 @@
<ImplicitUsings>enable</ImplicitUsings>
<AssemblyName>HyperBooru</AssemblyName>
<RootNamespace>HyperBooru</RootNamespace>
- <AssemblyVersion>0.18.0.0</AssemblyVersion>
+ <AssemblyVersion>0.19.0.0</AssemblyVersion>
<FileVersion>$(AssemblyVersion)</FileVersion>
- <Version>0.18-alpha</Version>
+ <Version>0.19-alpha</Version>
<UserSecretsId>2907567f-4640-4581-8f4d-0977952d26bd</UserSecretsId>
</PropertyGroup>
diff --git a/Services/MediaService.cs b/Services/MediaService.cs
index 2d1533c..a0521db 100644
--- a/Services/MediaService.cs
+++ b/Services/MediaService.cs
@@ -1,8 +1,10 @@
using HyperBooru.ApiModels;
+using HyperBooru.Util;
using ImageMagick;
using Microsoft.EntityFrameworkCore;
using MimeDetective;
using MimeDetective.Definitions;
+using System.Diagnostics.CodeAnalysis;
using System.Security.Cryptography;
using System.Text.RegularExpressions;
@@ -230,7 +232,10 @@ public class MediaService : IMediaService {
public void Delete(Guid media) {
using var db = dbFactory.CreateDbContext();
- var m = db.Media.First(m => m.Guid == media);
+ var m = db.Media.FirstOrDefault(m => m.Guid == media);
+
+ if(m is null)
+ throw new ObjectNotFoundException([ media ]);
var path = Path.Join(
config.MediaBasePath,
@@ -391,10 +396,11 @@ public class MediaService : IMediaService {
public string GetConvertedPath(Media media, string mimeType) =>
GetConvertedPath(media.Guid, mimeType);
- private int GetUploadedFileHash(UploadedFile uf) => (
- uf.CreateTime,
- uf.LastWriteTime,
- uf.Filename,
- uf.Length,
- uf.Checksum).GetHashCode();
+ private int GetUploadedFileHash(UploadedFile uf) =>
+ HashCode.Combine(
+ uf.CreateTime?.GetRoundedHashCode(),
+ uf.LastWriteTime?.GetRoundedHashCode(),
+ uf.Filename,
+ uf.Length,
+ uf.Checksum);
}
diff --git a/Util.cs b/Util.cs
index 7de2b6e..532064e 100644
--- a/Util.cs
+++ b/Util.cs
@@ -35,6 +35,11 @@ public static class Extensions {
return string.Format("{0:0}h{0:0}m", t.TotalHours, t.Minutes);
return string.Format("{0:0.00}d", t.TotalDays);
}
+
+ public static int GetRoundedHashCode(this DateTime dt) {
+ var t = dt.ToUniversalTime();
+ return HashCode.Combine(t.Year, t.Month, t.Date, t.Hour, t.Minute, t.Second);
+ }
}
public class LimitedConcurrencyTaskScheduler : TaskScheduler {