From 68764970ca6758946ba42e6afef6ba8e7ebf4920 Mon Sep 17 00:00:00 2001 From: Victor Nova Date: Sun, 16 Feb 2025 12:33:40 -0800 Subject: [PATCH] removed dependency on IHttpContextAccessor because HasIso8601FractionBug was always returning true anyway, and it was the only place that used it --- .../AzureBlobCollectionPropertyManager.cs | 6 ++-- .../AzureBlob/AzureBlobItemPropertyManager.cs | 6 ++-- ...AzureContainerCollectionPropertyManager.cs | 6 ++-- NWebDav.Server/Props/DavTypedProperties.cs | 33 ++++++------------- NWebDav.Server/Props/StandardProperties.cs | 3 +- .../DiskStoreCollectionPropertyManager.cs | 6 ++-- .../Stores/DiskStoreItemPropertyManager.cs | 6 ++-- 7 files changed, 26 insertions(+), 40 deletions(-) diff --git a/NWebDav.Sample.AzureBlob/AzureBlob/AzureBlobCollectionPropertyManager.cs b/NWebDav.Sample.AzureBlob/AzureBlob/AzureBlobCollectionPropertyManager.cs index 6f36dee..0d2ebce 100644 --- a/NWebDav.Sample.AzureBlob/AzureBlob/AzureBlobCollectionPropertyManager.cs +++ b/NWebDav.Sample.AzureBlob/AzureBlob/AzureBlobCollectionPropertyManager.cs @@ -12,14 +12,14 @@ internal class AzureBlobCollectionPropertyManager : PropertyManager[] GetProperties(IHttpContextAccessor httpContextAccessor, ILockingManager lockingManager) => new DavProperty[] + private static DavProperty[] GetProperties(ILockingManager lockingManager) => new DavProperty[] { // RFC-2518 properties - new DavCreationDate(httpContextAccessor) + new DavCreationDate() { Getter = collection => collection.StoreItemMetadata.CreatedOn, }, diff --git a/NWebDav.Sample.AzureBlob/AzureBlob/AzureBlobItemPropertyManager.cs b/NWebDav.Sample.AzureBlob/AzureBlob/AzureBlobItemPropertyManager.cs index 4dadaa4..f4f2f2a 100644 --- a/NWebDav.Sample.AzureBlob/AzureBlob/AzureBlobItemPropertyManager.cs +++ b/NWebDav.Sample.AzureBlob/AzureBlob/AzureBlobItemPropertyManager.cs @@ -7,14 +7,14 @@ namespace NWebDav.Sample.AzureBlob.AzureBlob; internal class AzureBlobItemPropertyManager : PropertyManager { - public AzureBlobItemPropertyManager(IHttpContextAccessor httpContextAccessor, ILockingManager lockingManager) : base(GetProperties(httpContextAccessor, lockingManager)) + public AzureBlobItemPropertyManager(ILockingManager lockingManager) : base(GetProperties(lockingManager)) { } - private static DavProperty[] GetProperties(IHttpContextAccessor httpContextAccessor, ILockingManager lockingManager) => new DavProperty[] + private static DavProperty[] GetProperties(ILockingManager lockingManager) => new DavProperty[] { // RFC-2518 properties - new DavCreationDate(httpContextAccessor) + new DavCreationDate() { Getter = item => item.StoreItemMetadata.CreatedOn, }, diff --git a/NWebDav.Sample.AzureBlob/AzureBlob/AzureContainerCollectionPropertyManager.cs b/NWebDav.Sample.AzureBlob/AzureBlob/AzureContainerCollectionPropertyManager.cs index e94e149..18e541c 100644 --- a/NWebDav.Sample.AzureBlob/AzureBlob/AzureContainerCollectionPropertyManager.cs +++ b/NWebDav.Sample.AzureBlob/AzureBlob/AzureContainerCollectionPropertyManager.cs @@ -13,14 +13,14 @@ internal class AzureContainerCollectionPropertyManager : PropertyManager[] GetProperties(IHttpContextAccessor httpContextAccessor, ILockingManager lockingManager) => new DavProperty[] + private static DavProperty[] GetProperties(ILockingManager lockingManager) => new DavProperty[] { // RFC-2518 properties - new DavCreationDate(httpContextAccessor) + new DavCreationDate() { Getter = _ => DateTime.UnixEpoch, }, diff --git a/NWebDav.Server/Props/DavTypedProperties.cs b/NWebDav.Server/Props/DavTypedProperties.cs index 430b334..e368faa 100644 --- a/NWebDav.Server/Props/DavTypedProperties.cs +++ b/NWebDav.Server/Props/DavTypedProperties.cs @@ -188,18 +188,16 @@ public abstract class DavIso8601Date : DavTypedProperty XmlConvert.ToDateTime((string)value, XmlDateTimeSerializationMode.Utc); - private bool HasIso8601FractionBug - { - get - { - var userAgent = _httpContextAccessor.HttpContext?.Request.Headers.UserAgent.FirstOrDefault(); - _ = userAgent; // TODO: Determine if this bug is present based on the user-agent - return true; - } - } } /// diff --git a/NWebDav.Server/Props/StandardProperties.cs b/NWebDav.Server/Props/StandardProperties.cs index 54b0524..e8bddc7 100644 --- a/NWebDav.Server/Props/StandardProperties.cs +++ b/NWebDav.Server/Props/StandardProperties.cs @@ -1,5 +1,4 @@ using System.Xml.Linq; -using Microsoft.AspNetCore.Http; using NWebDav.Server.Stores; namespace NWebDav.Server.Props; @@ -25,7 +24,7 @@ public class DavCreationDate : DavIso8601Date where TEntry : ISt // ReSharper disable once StaticMemberInGenericType public static readonly XName PropertyName = WebDavNamespaces.DavNs + "creationdate"; - public DavCreationDate(IHttpContextAccessor httpContextAccessor) : base(httpContextAccessor) + public DavCreationDate() : base() {} /// diff --git a/NWebDav.Server/Stores/DiskStoreCollectionPropertyManager.cs b/NWebDav.Server/Stores/DiskStoreCollectionPropertyManager.cs index e5a9dae..141b9c7 100644 --- a/NWebDav.Server/Stores/DiskStoreCollectionPropertyManager.cs +++ b/NWebDav.Server/Stores/DiskStoreCollectionPropertyManager.cs @@ -11,14 +11,14 @@ public class DiskStoreCollectionPropertyManager : PropertyManager[] GetProperties(IHttpContextAccessor httpContextAccessor, ILockingManager lockingManager) => new DavProperty[] + private static DavProperty[] GetProperties(ILockingManager lockingManager) => new DavProperty[] { // RFC-2518 properties - new DavCreationDate(httpContextAccessor) + new DavCreationDate() { Getter = collection => collection.DirectoryInfo.CreationTimeUtc, Setter = (collection, value) => diff --git a/NWebDav.Server/Stores/DiskStoreItemPropertyManager.cs b/NWebDav.Server/Stores/DiskStoreItemPropertyManager.cs index 5c23a10..48a4f83 100644 --- a/NWebDav.Server/Stores/DiskStoreItemPropertyManager.cs +++ b/NWebDav.Server/Stores/DiskStoreItemPropertyManager.cs @@ -11,14 +11,14 @@ namespace NWebDav.Server.Stores; public class DiskStoreItemPropertyManager : PropertyManager { - public DiskStoreItemPropertyManager(IHttpContextAccessor httpContextAccessor, ILockingManager lockingManager) : base(GetProperties(httpContextAccessor, lockingManager)) + public DiskStoreItemPropertyManager(ILockingManager lockingManager) : base(GetProperties(lockingManager)) { } - private static DavProperty[] GetProperties(IHttpContextAccessor httpContextAccessor, ILockingManager lockingManager) => new DavProperty[] + private static DavProperty[] GetProperties(ILockingManager lockingManager) => new DavProperty[] { // RFC-2518 properties - new DavCreationDate(httpContextAccessor) + new DavCreationDate() { Getter = item => item.FileInfo.CreationTimeUtc, Setter = (item, value) =>