-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from ramondeklein/net7.0
Implement proper .NET Core support
- Loading branch information
Showing
160 changed files
with
7,555 additions
and
8,127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- net7.0 | ||
pull_request: | ||
branches: | ||
- net7.0 | ||
|
||
jobs: | ||
build: | ||
env: | ||
BUILD_CONFIG: 'Release' | ||
VERSION: '0.0.0' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set Version Variable | ||
if: ${{ github.ref_type == 'tag' }} | ||
env: | ||
TAG: ${{ github.ref_name }} | ||
run: echo "VERSION=${TAG#v}" >> $GITHUB_ENV | ||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: 7.0.x | ||
- name: Restore dependencies | ||
run: dotnet restore | ||
- name: Build | ||
run: dotnet build --configuration $BUILD_CONFIG --no-restore /p:Version=$VERSION | ||
- name: Create NuGet package | ||
run: dotnet pack --output nupkgs --configuration $BUILD_CONFIG --no-restore --no-build /p:PackageVersion=$VERSION | ||
- name: Publish NuGet package | ||
if: github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v') | ||
run: nuget push nupkgs\*.nupkg -s 'https://api.nuget.org/v3/index.json' -k ${{secrets.NUGET_API_KEY}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
.idea | ||
.vs | ||
.vscode | ||
nuget.apikey | ||
packages/ | ||
Certificates/ | ||
*/obj/ | ||
*/bin/ | ||
*.suo | ||
*.nupkg | ||
**/*.lock.json | ||
**/*.user | ||
**/*.userprefs | ||
.vscode | ||
Help/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
$DAYS=3650 | ||
$PASSWORD='nwebdav' | ||
$OPENSSL_CMD="docker" | ||
$OPENSSL_ARG=@("run","--rm","-v","$(Get-Location)/Certificates:/data","alpine/openssl") | ||
|
||
New-Item -ItemType Directory -Force certificates | ||
|
||
Write-Host "Generate CA" | ||
& $OPENSSL_CMD ($OPENSSL_ARG+@("req","-x509","-nodes","-new","-sha256","-days","$DAYS","-newkey","rsa:2048","-keyout","data/RootCA.key","-out","data/RootCA.pem","-subj","/C=NL/CN=NWebDAV-Development-CA")) | ||
& $OPENSSL_CMD ($OPENSSL_ARG+@("x509","-outform","pem","-in","data/RootCA.pem","-out","data/RootCA.crt")) | ||
|
||
Write-Host "Generate localhost certificate" | ||
Copy-Item domains.ext certificates | ||
& $OPENSSL_CMD ($OPENSSL_ARG+@("req","-new","-nodes","-newkey","rsa:2048","-keyout","data/localhost.key","-out","data/localhost.csr","-subj","/C=NL/ST=Overijssel/L=Enschede/O=Localhost/CN=localhost")) | ||
& $OPENSSL_CMD ($OPENSSL_ARG+@("x509","-req","-sha256","-days","$DAYS","-in","data/localhost.csr","-CA","data/RootCA.pem","-CAkey","data/RootCA.key","-CAcreateserial","-extfile","/data/domains.ext","-out","data/localhost.crt")) | ||
& $OPENSSL_CMD ($OPENSSL_ARG+@("pkcs12","-export","-out","data/localhost.pfx","-inkey","data/localhost.key","-in","data/localhost.crt","-certfile","data/RootCA.crt","-passout","pass:$PASSWORD")) | ||
|
||
Write-Host "Import certificate (run as administrator if this fails)" | ||
Import-Certificate -FilePath certificates/RootCA.pem -CertStoreLocation Cert:\LocalMachine\Root |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Azure.Storage.Blobs; | ||
using Azure.Storage.Blobs.Models; | ||
using NWebDav.Server.Props; | ||
|
||
namespace NWebDav.Sample.AzureBlob.AzureBlob; | ||
|
||
internal abstract class AzureBlobBase | ||
{ | ||
protected AzureBlobBase(AzureBlobStore store, BlobContainerClient blobContainerClient, IPropertyManager propertyManager, IStoreItemMetadata storeItemMetadata) | ||
{ | ||
StoreItemMetadata = storeItemMetadata; | ||
Store = store; | ||
BlobContainerClient = blobContainerClient; | ||
PropertyManager = propertyManager; | ||
} | ||
|
||
internal IStoreItemMetadata StoreItemMetadata { get; } | ||
|
||
protected AzureBlobStore Store { get; } | ||
protected BlobContainerClient BlobContainerClient { get; } | ||
protected string Path => StoreItemMetadata.Path; | ||
protected BlobClient BlobClient => BlobContainerClient.GetBlobClient(Path); | ||
|
||
public string Name => !string.IsNullOrEmpty(Path) ? System.IO.Path.GetFileName(Path) : BlobContainerClient.Name; | ||
public string UniqueKey => BlobContainerClient.Name + '/' + Path; | ||
|
||
public IPropertyManager? PropertyManager { get; } | ||
} | ||
|
||
internal interface IStoreItemMetadata | ||
{ | ||
string Path { get; } | ||
bool IsFolder { get; } | ||
DateTime CreatedOn { get; } | ||
long ContentLength { get; } | ||
string ContentType { get; } | ||
string ETag { get; } | ||
|
||
} | ||
|
||
// We need this to bridge the difference between BlobProperties and BlobItemProperties | ||
internal sealed class StoreItemMetadata : IStoreItemMetadata | ||
{ | ||
public static StoreItemMetadata Root { get; } = new(); | ||
|
||
private StoreItemMetadata() | ||
{ | ||
Path = string.Empty; | ||
IsFolder = true; | ||
CreatedOn = DateTime.UnixEpoch; | ||
ContentLength = 0; | ||
ContentType = string.Empty; | ||
ETag = string.Empty; | ||
} | ||
|
||
private static bool DetermineIsFolder(IDictionary<string, string> metadata) => metadata.TryGetValue("Folder", out _); | ||
|
||
public StoreItemMetadata(string path, BlobProperties blobProperties) | ||
{ | ||
Path = path; | ||
IsFolder = DetermineIsFolder(blobProperties.Metadata); | ||
CreatedOn = blobProperties.CreatedOn.DateTime; | ||
ContentLength = blobProperties.ContentLength; | ||
ContentType = blobProperties.ContentType ?? string.Empty; | ||
ETag = blobProperties.ETag.ToString(); | ||
} | ||
|
||
public StoreItemMetadata(string path, BlobItemProperties blobItemProperties, IDictionary<string, string> metadata) | ||
{ | ||
Path = path; | ||
IsFolder = DetermineIsFolder(metadata); | ||
CreatedOn = blobItemProperties.CreatedOn?.DateTime ?? DateTime.UnixEpoch; | ||
ContentLength = blobItemProperties.ContentLength ?? 0L; | ||
ContentType = blobItemProperties.ContentType ?? string.Empty; | ||
ETag = blobItemProperties.ETag?.ToString() ?? string.Empty; | ||
} | ||
|
||
public string Path { get; } | ||
public bool IsFolder { get; } | ||
public DateTime CreatedOn { get; } | ||
public long ContentLength { get; } | ||
public string ContentType { get; } | ||
public string ETag { get; } | ||
} |
Oops, something went wrong.