Skip to content

Commit 1b15eed

Browse files
committed
v14.0.13424-Beta
1 parent 8011eed commit 1b15eed

File tree

192 files changed

+46868
-50479
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

192 files changed

+46868
-50479
lines changed

CS/CalDAVServer.FileSystemStorage.AspNetCore/CalDAVServer.FileSystemStorage.AspNetCore.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
<Project Sdk="Microsoft.NET.Sdk.Web">
33
<PropertyGroup>
4-
<VersionPrefix>13.4.13237</VersionPrefix>
4+
<VersionPrefix>14.0.13424-Beta</VersionPrefix>
55
<AssemblyName>CalDAVServer.FileSystemStorage.AspNetCore</AssemblyName>
66
<TargetFramework>net8.0</TargetFramework>
77
<LangVersion>9.0</LangVersion>
@@ -16,9 +16,9 @@
1616
</Content>
1717
</ItemGroup>
1818
<ItemGroup>
19-
<PackageReference Include="ITHit.Server" Version="13.4.13237" />
20-
<PackageReference Include="ITHit.Server.Core" Version="13.4.13237" />
21-
<PackageReference Include="ITHit.WebDAV.Server" Version="13.4.13237" />
19+
<PackageReference Include="ITHit.Server" Version="14.0.13424-Beta" />
20+
<PackageReference Include="ITHit.Server.Core" Version="14.0.13424-Beta" />
21+
<PackageReference Include="ITHit.WebDAV.Server" Version="14.0.13424-Beta" />
2222
<PackageReference Include="System.Data.OleDb" Version="8.0.0" />
2323
</ItemGroup>
2424
<ItemGroup>

CS/CalDAVServer.FileSystemStorage.AspNetCore/Config/DavContextConfig.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,6 @@ public static async Task ReadConfigurationAsync(this IConfigurationSection confi
6565
{
6666
FileSystemInfoExtension.UseFileSystemAttribute(new FileSystemExtendedAttribute(config.AttrStoragePath, config.RepositoryPath));
6767
}
68-
else if (!await new DirectoryInfo(config.RepositoryPath).IsExtendedAttributesSupportedAsync())
69-
{
70-
var tempPath = Path.Combine(Path.GetTempPath(), System.Reflection.Assembly.GetExecutingAssembly().GetName().Name);
71-
FileSystemInfoExtension.UseFileSystemAttribute(new FileSystemExtendedAttribute(tempPath, config.RepositoryPath));
72-
}
7368
}
7469
}
7570
}

CS/CalDAVServer.FileSystemStorage.AspNetCore/DavFile.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ public virtual async Task<bool> WriteAsync(Stream content, string contentType, l
152152
if (startIndex == 0 && fileInfo.Length > 0)
153153
{
154154
await using (FileStream filestream = fileInfo.Open(FileMode.Truncate)) { }
155+
156+
// Refresh file state since file was truncated.
157+
fileInfo.Refresh();
155158
}
156159
await WriteInternalAsync(content, contentType, startIndex, totalFileSize);
157160
return true;
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
using System;
2+
using System.IO;
3+
using System.Runtime.InteropServices;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace CalDAVServer.FileSystemStorage.AspNetCore.ExtendedAttributes
8+
{
9+
/// <summary>
10+
/// Provides methods for reading and writing extended attributes on files and folders.
11+
/// NTFS alternate data streams are used to store attributes.
12+
/// </summary>
13+
public class ExtendedAttribute : IExtendedAttribute
14+
{
15+
private readonly string pathFormat = "{0}:{1}";
16+
17+
/// <summary>
18+
/// Checks extended attribute existence.
19+
/// </summary>
20+
/// <param name="path">File or folder path.</param>
21+
/// <param name="attribName">Attribute name.</param>
22+
/// <returns>True if attribute exist, false otherwise.</returns>
23+
public async Task<bool> HasExtendedAttributeAsync(string path, string attribName)
24+
{
25+
if (string.IsNullOrEmpty(path)) throw new ArgumentNullException(nameof(path));
26+
if (string.IsNullOrEmpty(attribName)) throw new ArgumentNullException(nameof(attribName));
27+
28+
bool attributeExists = true;
29+
string fullPath = string.Format(pathFormat, path, attribName);
30+
31+
if (!File.Exists(fullPath))
32+
{
33+
attributeExists = false;
34+
}
35+
return attributeExists;
36+
}
37+
38+
/// <summary>
39+
/// Deletes extended attribute.
40+
/// </summary>
41+
/// <param name="path">File or folder path.</param>
42+
/// <param name="attribName">Attribute name.</param>
43+
public async Task DeleteExtendedAttributeAsync(string path, string attribName)
44+
{
45+
if (string.IsNullOrEmpty(path))
46+
{
47+
throw new ArgumentNullException("path");
48+
}
49+
50+
if (string.IsNullOrEmpty(attribName))
51+
{
52+
throw new ArgumentNullException("attribName");
53+
}
54+
55+
string fullPath = string.Format(pathFormat, path, attribName);
56+
File.Delete(fullPath);
57+
}
58+
59+
/// <summary>
60+
/// Gets extended attribute.
61+
/// </summary>
62+
/// <param name="path">File or folder path.</param>
63+
/// <param name="attribName">Attribute name.</param>
64+
/// <returns>Attribute value or null if attribute or file not found.</returns>
65+
public async Task<string> GetExtendedAttributeAsync(string path, string attribName)
66+
{
67+
if (string.IsNullOrEmpty(path))
68+
{
69+
throw new ArgumentNullException("path");
70+
}
71+
72+
if (string.IsNullOrEmpty(attribName))
73+
{
74+
throw new ArgumentNullException("attribName");
75+
}
76+
77+
string fullPath = string.Format(pathFormat, path, attribName);
78+
if (File.Exists(fullPath))
79+
{
80+
await using (FileStream fileStream = File.Open(fullPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete))
81+
using (StreamReader streamReader = new StreamReader(fileStream))
82+
{
83+
return await streamReader.ReadToEndAsync();
84+
}
85+
}
86+
87+
return null;
88+
}
89+
90+
/// <summary>
91+
/// Sets extended attribute.
92+
/// </summary>
93+
/// <param name="path">File or folder path.</param>
94+
/// <param name="attribName">Attribute name.</param>
95+
/// <param name="attribValue">Attribute value.</param>
96+
public async Task SetExtendedAttributeAsync(string path, string attribName, string attribValue)
97+
{
98+
if (string.IsNullOrEmpty(path))
99+
{
100+
throw new ArgumentNullException("path");
101+
}
102+
103+
if (string.IsNullOrEmpty(attribName))
104+
{
105+
throw new ArgumentNullException("attribName");
106+
}
107+
108+
if (attribValue == null)
109+
{
110+
throw new ArgumentNullException("attribValue");
111+
}
112+
113+
string fullPath = string.Format(pathFormat, path, attribName);
114+
await using (FileStream fileStream = File.Open(fullPath, FileMode.Create, FileAccess.Write, FileShare.ReadWrite | FileShare.Delete))
115+
await using (StreamWriter streamWriter = new StreamWriter(fileStream))
116+
{
117+
await streamWriter.WriteAsync(attribValue);
118+
}
119+
}
120+
121+
public Task DeleteExtendedAttributes(string path)
122+
{
123+
throw new NotImplementedException();
124+
}
125+
126+
public Task MoveExtendedAttributes(string sourcePath, string destinationPath)
127+
{
128+
throw new NotImplementedException();
129+
}
130+
131+
public Task CopyExtendedAttributes(string sourcePath, string destinationPath)
132+
{
133+
throw new NotImplementedException();
134+
}
135+
}
136+
}

CS/CalDAVServer.FileSystemStorage.AspNetCore/ExtendedAttributes/FileSystemExtendedAttribute.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,6 @@ public FileSystemExtendedAttribute(string attrStoragePath, string dataStoragePat
3636
this.DataStoragePath = System.IO.Path.GetFullPath(dataStoragePath);
3737
}
3838

39-
/// <summary>
40-
/// Determines whether extended attributes are supported.
41-
/// </summary>
42-
/// <param name="path">File or folder path.</param>
43-
/// <returns>True if extended attributes or NTFS file alternative streams are supported, false otherwise.</returns>
44-
public async Task<bool> IsExtendedAttributesSupportedAsync(string path)
45-
{
46-
return false;
47-
}
48-
4939
/// <summary>
5040
/// Checks extended attribute existence.
5141
/// </summary>

CS/CalDAVServer.FileSystemStorage.AspNetCore/ExtendedAttributes/FileSystemInfoExtension.cs

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ namespace CalDAVServer.FileSystemStorage.AspNetCore.ExtendedAttributes
1414
public static class FileSystemInfoExtension
1515
{
1616
/// <summary>
17-
/// Depending on OS holds WindowsExtendedAttribute, OSXExtendedAttribute or LinuxExtendedAttribute class instance.
17+
/// Implementation of <see cref="IExtendedAttribute"/>.
1818
/// </summary>
19-
private static IExtendedAttribute extendedAttribute;
19+
private static IExtendedAttribute extendedAttribute = new ExtendedAttribute();
2020

2121
/// <summary>
2222
/// Sets <see cref="FileSystemExtendedAttribute"/> as a storage for attributes.
@@ -36,54 +36,6 @@ public static bool IsUsingFileSystemAttribute
3636
{
3737
get { return extendedAttribute is FileSystemExtendedAttribute; }
3838
}
39-
40-
/// <summary>
41-
/// Initializes static class members.
42-
/// </summary>
43-
static FileSystemInfoExtension()
44-
{
45-
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
46-
{
47-
extendedAttribute = new WindowsExtendedAttribute();
48-
}
49-
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
50-
{
51-
extendedAttribute = new LinuxExtendedAttribute();
52-
}
53-
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
54-
{
55-
extendedAttribute = new OSXExtendedAttribute();
56-
}
57-
else
58-
{
59-
throw new Exception("Not Supported OS");
60-
}
61-
}
62-
63-
/// <summary>
64-
/// Determines whether extended attributes are supported.
65-
/// </summary>
66-
/// <param name="info"><see cref="FileSystemInfo"/> instance.</param>
67-
/// <returns>True if extended attributes or NTFS file alternative streams are supported, false otherwise.</returns>
68-
public static async Task<bool> IsExtendedAttributesSupportedAsync(this FileSystemInfo info)
69-
{
70-
if (info == null)
71-
{
72-
throw new ArgumentNullException("info");
73-
}
74-
75-
return await extendedAttribute.IsExtendedAttributesSupportedAsync(info.FullName);
76-
}
77-
78-
/// <summary>
79-
/// Determines whether extended attributes are supported.
80-
/// </summary>
81-
/// <param name="info"><see cref="FileSystemInfo"/> instance.</param>
82-
/// <returns>True if extended attributes or NTFS file alternative streams are supported, false otherwise.</returns>
83-
public static bool IsExtendedAttributesSupported(this FileSystemInfo info)
84-
{
85-
return info.IsExtendedAttributesSupportedAsync().ConfigureAwait(false).GetAwaiter().GetResult();
86-
}
8739
/// <summary>
8840
/// Checks whether a FileInfo or DirectoryInfo object is a directory, or intended to be a directory.
8941
/// </summary>

CS/CalDAVServer.FileSystemStorage.AspNetCore/ExtendedAttributes/IExtendedAttribute.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@ namespace CalDAVServer.FileSystemStorage.AspNetCore.ExtendedAttributes
77
/// </summary>
88
public interface IExtendedAttribute
99
{
10-
/// <summary>
11-
/// Determines whether extended attributes are supported.
12-
/// </summary>
13-
/// <param name="path">File or folder path.</param>
14-
/// <returns>True if extended attributes or NTFS file alternative streams are supported, false otherwise.</returns>
15-
Task<bool> IsExtendedAttributesSupportedAsync(string path);
16-
1710
/// <summary>
1811
/// Checks extended attribute existence.
1912
/// </summary>

0 commit comments

Comments
 (0)