Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Commit

Permalink
List and Close Handles bugfixes:
Browse files Browse the repository at this point in the history
* Fixed bug where List and Close Handles wasn't working with snapshots
* Fixed inconsistent optional parameters
* Fixed bug where "marker" query parameter was "x-ms-marker"
* Added overloads to Close Handles accepting handleId as a ulong
  • Loading branch information
seanmcc-msft committed Apr 29, 2019
1 parent 18b0e53 commit 275749f
Show file tree
Hide file tree
Showing 11 changed files with 144 additions and 48 deletions.
22 changes: 11 additions & 11 deletions Lib/ClassLibraryCommon/File/CloudFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2861,7 +2861,7 @@ public virtual Task<IEnumerable<FileRange>> ListRangesAsync(long? offset, long?
/// <param name="operationContext">An <see cref="OperationContext"/> object that represents the context for the current operation.</param>
/// <returns>An enumerable collection of ranges.</returns>
[DoesServiceRequest]
public virtual FileHandleResultSegment ListHandlesSegmented(FileContinuationToken token, int? maxResults, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext)
public virtual FileHandleResultSegment ListHandlesSegmented(FileContinuationToken token = null, int? maxResults = null, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null)
{
FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient);
return Executor.ExecuteSync(
Expand Down Expand Up @@ -2910,14 +2910,14 @@ public virtual FileHandleResultSegment EndListHandlesSegmented(IAsyncResult asyn
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to observe while waiting for a task to complete.</param>
/// <returns>A <see cref="Task{T}"/> object that represents the current operation.</returns>
[DoesServiceRequest]
public virtual Task<FileHandleResultSegment> ListHandlesSegmentedAsync(FileContinuationToken token, int? maxResults, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
public virtual Task<FileHandleResultSegment> ListHandlesSegmentedAsync(FileContinuationToken token = null, int? maxResults = null, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null, CancellationToken? cancellationToken = null)
{
FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient);
return Executor.ExecuteAsync(
this.ListHandlesImpl(token, maxResults, accessCondition, modifiedOptions),
modifiedOptions.RetryPolicy,
operationContext,
cancellationToken);
cancellationToken ?? CancellationToken.None);
}
#endif

Expand All @@ -2930,7 +2930,7 @@ public virtual Task<FileHandleResultSegment> ListHandlesSegmentedAsync(FileConti
/// <param name="options">A <see cref="FileRequestOptions"/> object that specifies additional options for the request.</param>
/// <param name="operationContext">An <see cref="OperationContext"/> object that represents the context for the current operation.</param>
[DoesServiceRequest]
public virtual CloseFileHandleResultSegment CloseAllHandlesSegmented(FileContinuationToken token, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext)
public virtual CloseFileHandleResultSegment CloseAllHandlesSegmented(FileContinuationToken token = null, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null)
{
FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient);
return Executor.ExecuteSync(
Expand Down Expand Up @@ -2977,14 +2977,14 @@ public virtual CloseFileHandleResultSegment EndCloseAllHandlesSegmented(IAsyncRe
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to observe while waiting for a task to complete.</param>
/// <returns>A <see cref="Task{T}"/> object that represents the current operation.</returns>
[DoesServiceRequest]
public virtual Task<CloseFileHandleResultSegment> CloseAllHandlesSegmentedAsync(FileContinuationToken token, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
public virtual Task<CloseFileHandleResultSegment> CloseAllHandlesSegmentedAsync(FileContinuationToken token = null, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null, CancellationToken? cancellationToken = null)
{
FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient);
return Executor.ExecuteAsync(
this.CloseHandleImpl(token, Constants.HeaderConstants.AllFileHandles, accessCondition, modifiedOptions),
modifiedOptions.RetryPolicy,
operationContext,
cancellationToken);
cancellationToken ?? CancellationToken.None);
}
#endif

Expand All @@ -2998,7 +2998,7 @@ public virtual Task<CloseFileHandleResultSegment> CloseAllHandlesSegmentedAsync(
/// <param name="options">A <see cref="FileRequestOptions"/> object that specifies additional options for the request.</param>
/// <param name="operationContext">An <see cref="OperationContext"/> object that represents the context for the current operation.</param>
[DoesServiceRequest]
public virtual CloseFileHandleResultSegment CloseHandleSegmented(string handleId, FileContinuationToken token, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext)
public virtual CloseFileHandleResultSegment CloseHandleSegmented(string handleId, FileContinuationToken token = null, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null)
{
FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient);
return Executor.ExecuteSync(
Expand Down Expand Up @@ -3047,14 +3047,14 @@ public virtual CloseFileHandleResultSegment EndCloseHandleSegmented(IAsyncResult
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to observe while waiting for a task to complete.</param>
/// <returns>A <see cref="Task{T}"/> object that represents the current operation.</returns>
[DoesServiceRequest]
public virtual Task<CloseFileHandleResultSegment> CloseHandleSegmentedAsync(string handleId, FileContinuationToken token, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
public virtual Task<CloseFileHandleResultSegment> CloseHandleSegmentedAsync(string handleId, FileContinuationToken token = null, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null, CancellationToken? cancellationToken = null)
{
FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient);
return Executor.ExecuteAsync(
this.CloseHandleImpl(token, handleId, accessCondition, modifiedOptions),
modifiedOptions.RetryPolicy,
operationContext,
cancellationToken);
cancellationToken ?? CancellationToken.None);
}
#endif

Expand Down Expand Up @@ -4412,7 +4412,7 @@ private RESTCommand<FileHandleResultSegment> ListHandlesImpl(FileContinuationTok
getCmd.RetrieveResponseStream = true;
getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) =>
{
StorageRequestMessage msg = FileHttpRequestMessageFactory.ListHandles(uri, serverTimeout, maxResults, false, token, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials);
StorageRequestMessage msg = FileHttpRequestMessageFactory.ListHandles(uri, serverTimeout, this.Share.SnapshotTime, maxResults, false, token, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials);
FileHttpRequestMessageFactory.AddMetadata(msg, this.Metadata);
return msg;
};
Expand Down Expand Up @@ -4450,7 +4450,7 @@ private RESTCommand<CloseFileHandleResultSegment> CloseHandleImpl(FileContinuati
putCmd.RetrieveResponseStream = true;
putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) =>
{
StorageRequestMessage msg = FileHttpRequestMessageFactory.CloseHandle(uri, serverTimeout, handleId, false, token, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials);
StorageRequestMessage msg = FileHttpRequestMessageFactory.CloseHandle(uri, serverTimeout, this.Share.SnapshotTime, handleId, false, token, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials);
FileHttpRequestMessageFactory.AddMetadata(msg, this.Metadata);
return msg;
Expand Down
48 changes: 40 additions & 8 deletions Lib/ClassLibraryCommon/File/CloudFileDirectory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1122,14 +1122,14 @@ public virtual FileHandleResultSegment EndListHandlesSegmented(IAsyncResult asyn
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to observe while waiting for a task to complete.</param>
/// <returns>A <see cref="Task{T}"/> object that represents the current operation.</returns>
[DoesServiceRequest]
public virtual Task<FileHandleResultSegment> ListHandlesSegmentedAsync(FileContinuationToken token, int? maxResults, bool? recursive, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
public virtual Task<FileHandleResultSegment> ListHandlesSegmentedAsync(FileContinuationToken token = null, int? maxResults = null, bool? recursive = null, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null, CancellationToken? cancellationToken = null)
{
FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient);
return Executor.ExecuteAsync(
this.ListHandlesImpl(token, maxResults, recursive, accessCondition, modifiedOptions),
modifiedOptions.RetryPolicy,
operationContext,
cancellationToken);
cancellationToken ?? CancellationToken.None);
}
#endif

Expand Down Expand Up @@ -1192,36 +1192,51 @@ public virtual CloseFileHandleResultSegment EndCloseAllHandlesSegmented(IAsyncRe
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to observe while waiting for a task to complete.</param>
/// <returns>A <see cref="Task{T}"/> object that represents the current operation.</returns>
[DoesServiceRequest]
public virtual Task<CloseFileHandleResultSegment> CloseAllHandlesSegmentedAsync(FileContinuationToken token, bool? recursive, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
public virtual Task<CloseFileHandleResultSegment> CloseAllHandlesSegmentedAsync(FileContinuationToken token = null, bool? recursive = null, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null, CancellationToken? cancellationToken = null)
{
FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient);
return Executor.ExecuteAsync(
this.CloseHandleImpl(token, Constants.HeaderConstants.AllFileHandles, recursive, accessCondition, modifiedOptions),
modifiedOptions.RetryPolicy,
operationContext,
cancellationToken);
cancellationToken ?? CancellationToken.None);
}
#endif

#if SYNC
/// <summary>
/// Closes the specified SMB handle on this directory.
/// </summary>
/// <param name="handleId">Id of the handle.</param>
/// <param name="handleId">Id of the handle, "*" if all handles on the file.</param>
/// <param name="token">Continuation token for when closing the handle requires multiple service calls.</param>
/// <param name="recursive">Whether to recurse through this directory's sub files and folders. A lack of value is interpreted as false.</param>
/// <param name="accessCondition">An <see cref="AccessCondition"/> object that represents the access conditions for the file. If <c>null</c>, no condition is used.</param>
/// <param name="options">A <see cref="FileRequestOptions"/> object that specifies additional options for the request.</param>
/// <param name="operationContext">An <see cref="OperationContext"/> object that represents the context for the current operation.</param>
[DoesServiceRequest]
public virtual CloseFileHandleResultSegment CloseHandleSegmented(string handleId, FileContinuationToken token, bool? recursive = null, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null)
public virtual CloseFileHandleResultSegment CloseHandleSegmented(string handleId, FileContinuationToken token = null, bool? recursive = null, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null)
{
FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient);
return Executor.ExecuteSync(
this.CloseHandleImpl(token, handleId, recursive, accessCondition, modifiedOptions),
modifiedOptions.RetryPolicy,
operationContext);
}

/// <summary>
/// Closes the specified SMB handle on this directory.
/// </summary>
/// <param name="handleId">Id of the handle.</param>
/// <param name="token">Continuation token for when closing the handle requires multiple service calls.</param>
/// <param name="recursive">Whether to recurse through this directory's sub files and folders. A lack of value is interpreted as false.</param>
/// <param name="accessCondition">An <see cref="AccessCondition"/> object that represents the access conditions for the file. If <c>null</c>, no condition is used.</param>
/// <param name="options">A <see cref="FileRequestOptions"/> object that specifies additional options for the request.</param>
/// <param name="operationContext">An <see cref="OperationContext"/> object that represents the context for the current operation.</param>
[DoesServiceRequest]
public virtual CloseFileHandleResultSegment CloseHandleSegmented(ulong handleId, FileContinuationToken token = null, bool? recursive = null, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null)
{
return this.CloseHandleSegmented(handleId.ToString(), token, recursive, accessCondition, options, operationContext);
}
#endif

/// <summary>
Expand Down Expand Up @@ -1274,6 +1289,23 @@ public virtual Task<CloseFileHandleResultSegment> CloseHandleSegmentedAsync(stri
operationContext,
cancellationToken ?? CancellationToken.None);
}

/// <summary>
/// Returns a task that performs an asynchronous operation to close the specified SMB handle on this directory.
/// </summary>
/// <param name="handleId">Id of the handle.</param>
/// <param name="token">Continuation token for when closing the handle takes exceedingly long.</param>
/// <param name="recursive">Whether to recurse through this directory's sub files and folders. A lack of value is interpreted as false.</param>
/// <param name="accessCondition">An <see cref="AccessCondition"/> object that represents the access conditions for the file. If <c>null</c>, no condition is used.</param>
/// <param name="options">A <see cref="FileRequestOptions"/> object that specifies additional options for the request.</param>
/// <param name="operationContext">An <see cref="OperationContext"/> object that represents the context for the current operation.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to observe while waiting for a task to complete.</param>
/// <returns>A <see cref="Task{T}"/> object that represents the current operation.</returns>
[DoesServiceRequest]
public virtual Task<CloseFileHandleResultSegment> CloseHandleSegmentedAsync(ulong handleId, FileContinuationToken token = null, bool? recursive = null, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null, CancellationToken? cancellationToken = null)
{
return this.CloseHandleSegmentedAsync(handleId.ToString(), token, recursive, accessCondition, options, operationContext, cancellationToken);
}
#endif

#if SYNC
Expand Down Expand Up @@ -1478,7 +1510,7 @@ private RESTCommand<FileHandleResultSegment> ListHandlesImpl(FileContinuationTok
getCmd.RetrieveResponseStream = true;
getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) =>
{
StorageRequestMessage msg = FileHttpRequestMessageFactory.ListHandles(uri, serverTimeout, maxResults, recursive, token, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials);
StorageRequestMessage msg = FileHttpRequestMessageFactory.ListHandles(uri, serverTimeout, this.Share.SnapshotTime, maxResults, recursive, token, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials);
FileHttpRequestMessageFactory.AddMetadata(msg, this.Metadata);
return msg;
};
Expand Down Expand Up @@ -1518,7 +1550,7 @@ private RESTCommand<CloseFileHandleResultSegment> CloseHandleImpl(FileContinuati
putCmd.RetrieveResponseStream = true;
putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) =>
{
StorageRequestMessage msg = FileHttpRequestMessageFactory.CloseHandle(uri, serverTimeout, handleId, recursive, token, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials);
StorageRequestMessage msg = FileHttpRequestMessageFactory.CloseHandle(uri, serverTimeout, this.Share.SnapshotTime, handleId, recursive, token, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials);
FileHttpRequestMessageFactory.AddMetadata(msg, this.Metadata);
return msg;
};
Expand Down
Loading

0 comments on commit 275749f

Please sign in to comment.