Skip to content

Commit

Permalink
Implement follow-symlink
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmaZhu authored and vinjiang committed Dec 27, 2017
1 parent 9f2f398 commit d9cda3f
Show file tree
Hide file tree
Showing 10 changed files with 247 additions and 37 deletions.
Binary file modified .nuget/NuGet.exe
Binary file not shown.
9 changes: 9 additions & 0 deletions lib/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions lib/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,10 @@ MD5 in property: {2}</value>
<value>Failed to enumerate directory {0} with file pattern {1}.</value>
<comment>{0} is the directory path, {1} is file pattern.</comment>
</data>
<data name="EnumerateDirectoryException" xml:space="preserve">
<value>Failed to enumerate directory {0}.</value>
<comment>{0} is the directory path.</comment>
</data>
<data name="FailedToValidateDestinationException" xml:space="preserve">
<value>Failed to validate destination.</value>
</data>
Expand Down
219 changes: 190 additions & 29 deletions lib/TransferEnumerators/EnumerateDirectoryHelper.cs

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion lib/TransferEnumerators/FileEnumerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@ internal class FileEnumerator : TransferEnumeratorBase, ITransferEnumerator

private FileListContinuationToken listContinuationToken;

private bool followSymlink;

/// <summary>
/// Initializes a new instance of the <see cref="FileEnumerator" /> class.
/// </summary>
/// <param name="location">Directory location.</param>
public FileEnumerator(DirectoryLocation location)
/// <param name="followsymlink">Indicating whether to enumerate symlinked subdirectories.</param>
public FileEnumerator(DirectoryLocation location, bool followSymlink)
{
this.location = location;
this.followSymlink = followSymlink;
}

/// <summary>
Expand Down Expand Up @@ -92,6 +96,7 @@ public IEnumerable<TransferEntry> EnumerateLocation(CancellationToken cancellati
filePattern,
this.listContinuationToken == null ? null : this.listContinuationToken.FilePath,
searchOption,
followSymlink,
cancellationToken);
}
catch (Exception ex)
Expand Down
4 changes: 2 additions & 2 deletions lib/TransferManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ public static Task<TransferStatus> UploadDirectoryAsync(string sourcePath, Cloud
{
DirectoryLocation sourceLocation = new DirectoryLocation(sourcePath);
AzureBlobDirectoryLocation destLocation = new AzureBlobDirectoryLocation(destBlobDir);
FileEnumerator sourceEnumerator = new FileEnumerator(sourceLocation);
FileEnumerator sourceEnumerator = new FileEnumerator(sourceLocation, null != options? options.FollowSymlink : false);
if (options != null)
{
sourceEnumerator.SearchPattern = options.SearchPattern;
Expand Down Expand Up @@ -361,7 +361,7 @@ public static Task<TransferStatus> UploadDirectoryAsync(string sourcePath, Cloud
{
DirectoryLocation sourceLocation = new DirectoryLocation(sourcePath);
AzureFileDirectoryLocation destLocation = new AzureFileDirectoryLocation(destFileDir);
FileEnumerator sourceEnumerator = new FileEnumerator(sourceLocation);
FileEnumerator sourceEnumerator = new FileEnumerator(sourceLocation, options.FollowSymlink);
if (options != null)
{
sourceEnumerator.SearchPattern = options.SearchPattern;
Expand Down
24 changes: 24 additions & 0 deletions lib/TransferOptions/UploadDirectoryOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,40 @@
namespace Microsoft.WindowsAzure.Storage.DataMovement
{
using Microsoft.WindowsAzure.Storage.Blob;
using Microsoft.WindowsAzure.Storage.DataMovement.Interop;
using System;

/// <summary>
/// Represents a set of options that may be specified for upload directory operation
/// </summary>
public sealed class UploadDirectoryOptions : DirectoryOptions
{
private bool followSymlink = false;
/// <summary>
/// Gets or sets type of destination blob. This option takes effect only when uploading to Azure blob storage.
/// If blob type is not specified, BlockBlob is used.
/// </summary>
public BlobType BlobType { get; set; }

/// <summary>
/// Gets or sets whether to follow symlinked directories. This option only works in Unix/Linux platforms.
/// </summary>
public bool FollowSymlink
{
get
{
return this.followSymlink;
}

set
{
if (value && !CrossPlatformHelpers.IsLinux)
{
throw new PlatformNotSupportedException();
}

this.followSymlink = value;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>Microsoft.WindowsAzure.Storage.DataMovement Class Library</Description>
<Version>0.6.6.0</Version>
<Version>0.7.0.0</Version>
<Authors>Microsoft</Authors>
<TargetFramework>netstandard2.0</TargetFramework>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
Expand All @@ -25,10 +25,16 @@

<ItemGroup>
<Compile Include="..\..\lib\**\*.cs;..\..\tools\AssemblyInfo\*.cs" Exclude="bin\**;obj\**;**\*.xproj;packages\**" />
<EmbeddedResource Include="..\..\lib\Resources.resx" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="..\..\lib\Resources.resx" Link="Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Mono.Posix.NETStandard" Version="1.0.0-beta2" />
<PackageReference Include="System.Runtime.Serialization.Xml" Version="4.3.0" />
<PackageReference Include="System.Threading.ThreadPool" Version="4.3.0" />
<PackageReference Include="WindowsAzure.Storage" Version="8.6.0" />
Expand Down
4 changes: 2 additions & 2 deletions tools/AssemblyInfo/SharedAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
using System.Resources;
using System.Runtime.InteropServices;

[assembly: AssemblyVersion("0.6.6.0")]
[assembly: AssemblyFileVersion("0.6.6.0")]
[assembly: AssemblyVersion("0.7.0.0")]
[assembly: AssemblyFileVersion("0.7.0.0")]

[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Microsoft Azure Storage")]
Expand Down
3 changes: 2 additions & 1 deletion tools/nupkg/Microsoft.Azure.Storage.DataMovement.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata minClientVersion="2.12">
<id>Microsoft.Azure.Storage.DataMovement</id>
<version>0.6.6</version>
<version>0.7.0</version>
<title>Microsoft Azure Storage Data Movement Library</title>
<authors>Microsoft</authors>
<owners>Microsoft</owners>
Expand All @@ -22,6 +22,7 @@
<dependency id="WindowsAzure.Storage" version="8.6.0" />
</group>
<group targetFramework="netstandard2.0">
<dependency id="Mono.Posix.NETStandard" version="1.0.0-beta2" />
<dependency id="NETStandard.Library" version="1.6.0" />
<dependency id="WindowsAzure.Storage" version="8.6.0" />
<dependency id="System.Dynamic.Runtime" version="4.3.0" />
Expand Down

0 comments on commit d9cda3f

Please sign in to comment.