Skip to content

Commit b4e48ab

Browse files
authored
Merge pull request #21 from SharpGrip/8-new-adapter-google-drive
8 new adapter google drive
2 parents cd96648 + fed6208 commit b4e48ab

53 files changed

Lines changed: 1245 additions & 85 deletions

File tree

Some content is hidden

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

.github/workflows/Build.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ name: FileSystem [Build]
33
env:
44
JAVA_VERSION: 17
55
JAVA_DISTRIBUTION: microsoft
6-
DOTNET_VERSION: 7.0.x
6+
DOTNET_VERSION: |
7+
3.1.x
8+
6.0.x
9+
7.0.x
10+
8.0.x
711
DOTNET_BUILD_CONFIGURATION: Release
812
SONAR_PATH: .\.sonar\scanner
913
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
@@ -34,7 +38,7 @@ jobs:
3438
java-version: ${{ env.JAVA_VERSION }}
3539
distribution: ${{ env.JAVA_DISTRIBUTION }}
3640

37-
- name: Setup .NET
41+
- name: Set up .NET
3842
uses: actions/setup-dotnet@v3
3943
with:
4044
dotnet-version: ${{ env.DOTNET_VERSION }}
@@ -55,7 +59,7 @@ jobs:
5559
- name: Test solution
5660
run: dotnet test --no-build -c ${{ env.DOTNET_BUILD_CONFIGURATION }} --verbosity normal
5761

58-
- name: Cleanup solution
62+
- name: Clean solution
5963
run: dotnet clean
6064

6165
- name: Analyze solution

.github/workflows/Release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
with:
2323
fetch-depth: 0
2424

25-
- name: Setup .NET
25+
- name: Set up .NET
2626
uses: actions/setup-dotnet@v3
2727
with:
2828
dotnet-version: ${{ env.DOTNET_VERSION }}

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
3+
<TargetFrameworks>netstandard2.0;netstandard2.1;net6.0;net7.0;net8.0</TargetFrameworks>
44
<Nullable>enable</Nullable>
55
<LangVersion>8.0</LangVersion>
66
<NoWarn>NU1701</NoWarn>

FileSystem.Adapters.AmazonS3/src/AmazonS3Adapter.cs

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414

1515
namespace SharpGrip.FileSystem.Adapters.AmazonS3
1616
{
17-
public class AmazonS3Adapter : Adapter
17+
public class AmazonS3Adapter : Adapter<AmazonS3AdapterConfiguration, string, string>
1818
{
1919
private readonly IAmazonS3 client;
2020
private readonly string bucketName;
2121

22-
public AmazonS3Adapter(string prefix, string rootPath, IAmazonS3 client, string bucketName) : base(prefix, rootPath)
22+
public AmazonS3Adapter(string prefix, string rootPath, IAmazonS3 client, string bucketName, Action<AmazonS3AdapterConfiguration>? configuration = null) : base(prefix, rootPath, configuration)
2323
{
2424
this.client = client;
2525
this.bucketName = bucketName;
@@ -61,12 +61,7 @@ public override async Task<IFile> GetFileAsync(string virtualPath, CancellationT
6161

6262
public override async Task<IDirectory> GetDirectoryAsync(string virtualPath, CancellationToken cancellationToken = default)
6363
{
64-
var path = GetPath(virtualPath);
65-
66-
if (!path.EndsWith("/"))
67-
{
68-
path += "/";
69-
}
64+
var path = GetPath(virtualPath).RemoveLeadingForwardSlash().EnsureTrailingForwardSlash();
7065

7166
try
7267
{
@@ -109,12 +104,7 @@ public override async Task<IDirectory> GetDirectoryAsync(string virtualPath, Can
109104
public override async Task<IEnumerable<IFile>> GetFilesAsync(string virtualPath = "", CancellationToken cancellationToken = default)
110105
{
111106
await GetDirectoryAsync(virtualPath, cancellationToken);
112-
var path = GetPath(virtualPath);
113-
114-
if (!path.EndsWith("/"))
115-
{
116-
path += "/";
117-
}
107+
var path = GetPath(virtualPath).EnsureTrailingForwardSlash();
118108

119109
if (path == "/")
120110
{
@@ -134,7 +124,6 @@ public override async Task<IEnumerable<IFile>> GetFilesAsync(string virtualPath
134124

135125
foreach (var item in response.S3Objects)
136126
{
137-
// var itemName = item.Key.Substring(0, item.Key.Length - path.Length);
138127
var itemName = item.Key.Substring(path.Length).RemoveLeadingForwardSlash();
139128

140129
if (!item.Key.EndsWith("/") && !itemName.Contains('/'))
@@ -157,12 +146,7 @@ public override async Task<IEnumerable<IFile>> GetFilesAsync(string virtualPath
157146
public override async Task<IEnumerable<IDirectory>> GetDirectoriesAsync(string virtualPath = "", CancellationToken cancellationToken = default)
158147
{
159148
await GetDirectoryAsync(virtualPath, cancellationToken);
160-
var path = GetPath(virtualPath);
161-
162-
if (!path.EndsWith("/"))
163-
{
164-
path += "/";
165-
}
149+
var path = GetPath(virtualPath).EnsureTrailingForwardSlash();
166150

167151
if (path == "/")
168152
{
@@ -208,8 +192,7 @@ public override async Task CreateDirectoryAsync(string virtualPath, Cancellation
208192
throw new DirectoryExistsException(GetPath(virtualPath), Prefix);
209193
}
210194

211-
var path = GetPath(virtualPath);
212-
path = path.EndsWith("/") ? path : path + "/";
195+
var path = GetPath(virtualPath).EnsureTrailingForwardSlash();
213196

214197
try
215198
{
@@ -226,8 +209,7 @@ public override async Task DeleteDirectoryAsync(string virtualPath, Cancellation
226209
{
227210
await GetDirectoryAsync(virtualPath, cancellationToken);
228211

229-
var path = GetPath(virtualPath);
230-
path = path.EndsWith("/") ? path : path + "/";
212+
var path = GetPath(virtualPath).EnsureTrailingForwardSlash();
231213

232214
try
233215
{
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using SharpGrip.FileSystem.Configuration;
2+
3+
namespace SharpGrip.FileSystem.Adapters.AmazonS3
4+
{
5+
public class AmazonS3AdapterConfiguration : AdapterConfiguration
6+
{
7+
}
8+
}

FileSystem.Adapters.AzureBlobStorage/src/AzureBlobStorageAdapter.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414

1515
namespace SharpGrip.FileSystem.Adapters.AzureBlobStorage
1616
{
17-
public class AzureBlobStorageAdapter : Adapter
17+
public class AzureBlobStorageAdapter : Adapter<AzureBlobStorageAdapterConfiguration, string, string>
1818
{
1919
private readonly BlobContainerClient client;
2020

21-
public AzureBlobStorageAdapter(string prefix, string rootPath, BlobContainerClient client) : base(prefix, rootPath)
21+
public AzureBlobStorageAdapter(string prefix, string rootPath, BlobContainerClient client, Action<AzureBlobStorageAdapterConfiguration>? configuration = null)
22+
: base(prefix, rootPath, configuration)
2223
{
2324
this.client = client;
2425
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using SharpGrip.FileSystem.Configuration;
2+
3+
namespace SharpGrip.FileSystem.Adapters.AzureBlobStorage
4+
{
5+
public class AzureBlobStorageAdapterConfiguration : AdapterConfiguration
6+
{
7+
}
8+
}

FileSystem.Adapters.AzureFileStorage/src/AzureFileStorageAdapter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212

1313
namespace SharpGrip.FileSystem.Adapters.AzureFileStorage
1414
{
15-
public class AzureFileStorageAdapter : Adapter
15+
public class AzureFileStorageAdapter : Adapter<AzureFileStorageAdapterConfiguration, string, string>
1616
{
1717
private readonly ShareClient client;
1818

19-
public AzureFileStorageAdapter(string prefix, string rootPath, ShareClient client) : base(prefix, rootPath)
19+
public AzureFileStorageAdapter(string prefix, string rootPath, ShareClient client, Action<AzureFileStorageAdapterConfiguration>? configuration = null) : base(prefix, rootPath, configuration)
2020
{
2121
this.client = client;
2222
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using SharpGrip.FileSystem.Configuration;
2+
3+
namespace SharpGrip.FileSystem.Adapters.AzureFileStorage
4+
{
5+
public class AzureFileStorageAdapterConfiguration : AdapterConfiguration
6+
{
7+
}
8+
}

FileSystem.Adapters.Dropbox/src/DropboxAdapter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313

1414
namespace SharpGrip.FileSystem.Adapters.Dropbox
1515
{
16-
public class DropboxAdapter : Adapter
16+
public class DropboxAdapter : Adapter<DropboxAdapterConfiguration, string, string>
1717
{
1818
private readonly DropboxClient client;
1919

20-
public DropboxAdapter(string prefix, string rootPath, DropboxClient client) : base(prefix, rootPath)
20+
public DropboxAdapter(string prefix, string rootPath, DropboxClient client, Action<DropboxAdapterConfiguration>? configuration = null) : base(prefix, rootPath, configuration)
2121
{
2222
this.client = client;
2323
}

0 commit comments

Comments
 (0)