Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -258,4 +258,5 @@ paket-files/

# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
*.pyc
/.dotnet-home/
1 change: 1 addition & 0 deletions SFTPSync.sln
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.github\workflows\build.yml = .github\workflows\build.yml
LICENSE.md = LICENSE.md
README.md = README.md
UpdateSubModules.bat = UpdateSubModules.bat
EndProjectSection
EndProject
Global
Expand Down
41 changes: 36 additions & 5 deletions SFTPSyncLib/RemoteSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ public static async Task RunSharedInitialSyncAsync(
return;
}

localRootDirectory = Path.TrimEndingDirectorySeparator(Path.GetFullPath(localRootDirectory));
remoteRootDirectory = NormalizeRemoteRootDirectory(remoteRootDirectory);

try
{
using (var sftp = new SftpClient(host, username, password))
Expand Down Expand Up @@ -282,7 +285,8 @@ public async Task InitialSync(string localPath, string remotePath)
foreach (var item in localDirectories)
{
var directoryName = item.Split(Path.DirectorySeparatorChar).Last();
await InitialSync(localPath + "\\" + directoryName, remotePath + "/" + directoryName);
var nextRemotePath = AppendRemotePath(remotePath, directoryName);
await InitialSync(localPath + "\\" + directoryName, nextRemotePath);
}

await SyncDirectoryAsync(_sftp, localPath, remotePath, _searchPattern);
Expand Down Expand Up @@ -331,7 +335,7 @@ private static string[] FilteredDirectories(string localRootDirectory, string lo
.OrderBy(path => path, StringComparer.OrdinalIgnoreCase))
{
var directoryName = directory.Split(Path.DirectorySeparatorChar).Last();
var remotePath = current.RemotePath + "/" + directoryName;
var remotePath = AppendRemotePath(current.RemotePath, directoryName);
queue.Enqueue((directory, remotePath));
}
}
Expand Down Expand Up @@ -359,12 +363,13 @@ private static async Task CreateDirectoriesInternal(
foreach (var item in localDirectories)
{
var directoryName = item.Split(Path.DirectorySeparatorChar).Last();
var targetRemotePath = AppendRemotePath(remotePath, directoryName);
if (!remoteDirectories.ContainsKey(directoryName))
{
Logger.LogInfo($"Creating remote directory {remotePath}{directoryName}");
sftp.CreateDirectory(remotePath + "/" + directoryName);
Logger.LogInfo($"Creating remote directory {targetRemotePath}");
sftp.CreateDirectory(targetRemotePath);
}
await CreateDirectoriesInternal(sftp, localRootDirectory, localPath + "\\" + directoryName, remotePath + "/" + directoryName, excludedFolders);
await CreateDirectoriesInternal(sftp, localRootDirectory, localPath + "\\" + directoryName, targetRemotePath, excludedFolders);
}
}

Expand Down Expand Up @@ -421,6 +426,32 @@ private string GetRemotePathForLocal(string localPath)
return _remoteRootDirectory + "/" + relativePath;
}

private static string NormalizeRemoteRootDirectory(string remoteRootDirectory)
{
if (remoteRootDirectory == "/")
return "/";

return remoteRootDirectory.TrimEnd('/', '\\');
}

private static string AppendRemotePath(string remotePath, string segment)
{
if (string.IsNullOrEmpty(segment))
return remotePath;

var normalizedSegment = segment.Replace('\\', '/').Trim('/');
if (normalizedSegment.Length == 0)
return remotePath;

if (remotePath == "/")
return "/" + normalizedSegment;

if (string.IsNullOrEmpty(remotePath))
return normalizedSegment;

return remotePath + "/" + normalizedSegment;
}

private void EnsureConnected()
{
if (_disposed)
Expand Down
2 changes: 1 addition & 1 deletion SFTPSyncSetup/Product.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Id="*"
Name="SFTPSync"
Language="1033"
Version="1.7"
Version="1.8"
Manufacturer="Synergex International Corporation"
UpgradeCode="6000f870-b811-4e22-b80b-5b8956317d09">

Expand Down
2 changes: 1 addition & 1 deletion SFTPSyncSetup/SFTPSyncSetup.wixproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<ProductVersion>3.10</ProductVersion>
<ProjectGuid>5074cbcb-641b-4a9c-b3bc-8dd0b78810a6</ProjectGuid>
<SchemaVersion>2.0</SchemaVersion>
<OutputName>SFTPSync-1.7</OutputName>
<OutputName>SFTPSync-1.8</OutputName>
<OutputType>Package</OutputType>
<Name>SFTPSyncSetup</Name>
</PropertyGroup>
Expand Down
8 changes: 4 additions & 4 deletions SFTPSyncUI/SFTPSyncUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
<Company>Synergex International, Inc.</Company>
<AssemblyVersion>1.7</AssemblyVersion>
<FileVersion>1.7</FileVersion>
<AssemblyVersion>1.8</AssemblyVersion>
<FileVersion>1.8</FileVersion>
<LangVersion>preview</LangVersion>
<Version>1.7</Version>
<Version>1.8</Version>
</PropertyGroup>

<ItemGroup>
Expand All @@ -36,7 +36,7 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="docs\SFTPSync.chm">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="SFTPSyncUI.ico">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand Down
Binary file modified SFTPSyncUI/docs/SFTPSync.chm
Binary file not shown.
Binary file modified SFTPSyncUI/docs/SFTPSync_files/CompletedSettingsFile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified SFTPSyncUI/docs/SFTPSync_files/EmptySettingsDialog.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified SFTPSyncUI/docs/SFTPSync_files/SettingsFileContent.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions UpdateSubModules.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@echo off
pushd %~dp0

rem Keep submodules pinned to the commit recorded by this repo.
git submodule sync --recursive
git submodule update --init --recursive --checkout

rem Do not auto-pull submodule branches here; that makes the superproject dirty.

popd
Loading