@@ -73,6 +73,8 @@ public async Task Write(PluginParameters parameters, CancellationToken cancellat
7373 #region internal methods
7474 private async Task CreateEntity ( CreateParameters createParameters , CancellationToken cancellationToken )
7575 {
76+ cancellationToken . ThrowIfCancellationRequested ( ) ;
77+
7678 var path = PathHelper . ToUnixPath ( createParameters . Path ) ;
7779 if ( string . IsNullOrEmpty ( path ) )
7880 throw new Exception ( Resources . TheSpecifiedPathMustBeNotEmpty ) ;
@@ -99,6 +101,7 @@ private async Task<bool> BucketExists(string bucketName, CancellationToken cance
99101 {
100102 try
101103 {
104+ cancellationToken . ThrowIfCancellationRequested ( ) ;
102105 var bucketsResponse = await _client . ListBucketsAsync ( cancellationToken ) ;
103106 return bucketsResponse . Buckets . Any ( x => x . BucketName == bucketName ) ;
104107 }
@@ -110,6 +113,8 @@ private async Task<bool> BucketExists(string bucketName, CancellationToken cance
110113
111114 private async Task AddFolder ( string bucketName , string folderName , CancellationToken cancellationToken )
112115 {
116+ cancellationToken . ThrowIfCancellationRequested ( ) ;
117+
113118 if ( ! folderName . EndsWith ( PathHelper . PathSeparator ) )
114119 folderName += PathHelper . PathSeparator ;
115120
@@ -127,6 +132,8 @@ private async Task AddFolder(string bucketName, string folderName, CancellationT
127132
128133 private async Task DeleteEntity ( DeleteParameters deleteParameters , CancellationToken cancellationToken )
129134 {
135+ cancellationToken . ThrowIfCancellationRequested ( ) ;
136+
130137 var path = PathHelper . ToUnixPath ( deleteParameters . Path ) ;
131138 if ( string . IsNullOrEmpty ( path ) )
132139 throw new Exception ( Resources . TheSpecifiedPathMustBeNotEmpty ) ;
@@ -151,6 +158,8 @@ await _client
151158
152159 private async Task < bool > ExistEntity ( string path , CancellationToken cancellationToken )
153160 {
161+ cancellationToken . ThrowIfCancellationRequested ( ) ;
162+
154163 path = PathHelper . ToUnixPath ( path ) ;
155164 if ( string . IsNullOrEmpty ( path ) )
156165 throw new Exception ( Resources . TheSpecifiedPathMustBeNotEmpty ) ;
@@ -170,6 +179,8 @@ private async Task<bool> ExistEntity(string path, CancellationToken cancellation
170179 private async Task < IEnumerable < PluginContext > > ListEntities ( ListParameters listParameters ,
171180 CancellationToken cancellationToken )
172181 {
182+ cancellationToken . ThrowIfCancellationRequested ( ) ;
183+
173184 var path = PathHelper . ToUnixPath ( listParameters . Path ) ;
174185
175186 if ( string . IsNullOrEmpty ( path ) )
@@ -207,11 +218,15 @@ private async Task<List<PluginContext>> ListObjects(string bucketName, ListParam
207218
208219 do
209220 {
221+ cancellationToken . ThrowIfCancellationRequested ( ) ;
222+
210223 var response = await _client . ListObjectsV2Async ( request , cancellationToken ) . ConfigureAwait ( false ) ;
211224 continuationToken = response . NextContinuationToken ;
212225
213226 foreach ( var obj in response . S3Objects )
214227 {
228+ cancellationToken . ThrowIfCancellationRequested ( ) ;
229+
215230 if ( obj . Key . EndsWith ( PathHelper . PathSeparator ) )
216231 continue ;
217232
@@ -249,6 +264,8 @@ private async Task<List<PluginContext>> ListObjects(string bucketName, ListParam
249264
250265 private async Task PurgeEntity ( PurgeParameters purgeParameters , CancellationToken cancellationToken )
251266 {
267+ cancellationToken . ThrowIfCancellationRequested ( ) ;
268+
252269 var path = PathHelper . ToUnixPath ( purgeParameters . Path ) ;
253270 var folder = path ;
254271 if ( ! folder . EndsWith ( PathHelper . PathSeparator ) )
@@ -259,6 +276,8 @@ private async Task PurgeEntity(PurgeParameters purgeParameters, CancellationToke
259276
260277 private async Task < PluginContext > ReadEntity ( ReadParameters readParameters , CancellationToken cancellationToken )
261278 {
279+ cancellationToken . ThrowIfCancellationRequested ( ) ;
280+
262281 var path = PathHelper . ToUnixPath ( readParameters . Path ) ;
263282 if ( string . IsNullOrEmpty ( path ) )
264283 throw new Exception ( Resources . TheSpecifiedPathMustBeNotEmpty ) ;
@@ -282,6 +301,8 @@ private async Task<PluginContext> ReadEntity(ReadParameters readParameters, Canc
282301
283302 private async Task WriteEntity ( WriteParameters writeParameters , CancellationToken cancellationToken )
284303 {
304+ cancellationToken . ThrowIfCancellationRequested ( ) ;
305+
285306 var path = PathHelper . ToUnixPath ( writeParameters . Path ) ;
286307 if ( string . IsNullOrEmpty ( path ) )
287308 throw new Exception ( Resources . TheSpecifiedPathMustBeNotEmpty ) ;
@@ -337,6 +358,8 @@ private PluginContext CreateContextFromStringData(string path, string data)
337358 private async Task WriteEntityFromContext ( string path , PluginContext context , bool overwrite ,
338359 CancellationToken cancellationToken )
339360 {
361+ cancellationToken . ThrowIfCancellationRequested ( ) ;
362+
340363 byte [ ] dataToWrite ;
341364
342365 if ( context . RawData is not null )
0 commit comments