diff options
| author | Joel Klinghed <the_jk@spawned.biz> | 2024-11-09 16:17:44 +0100 |
|---|---|---|
| committer | Joel Klinghed <the_jk@spawned.biz> | 2024-11-09 16:17:44 +0100 |
| commit | 882520f3baee410647c3b99d608cc8fe18b0f5d0 (patch) | |
| tree | eebb370a4977ea20ce3cfaf679aff387ab0896c9 /libs/sftp/src/main/java | |
| parent | 6ea5cef180db16523b2d629a44ee556507e3de78 (diff) | |
sftp: add single merge tests for both local <-> sftp and sftp <-> local
Had to fixup the symlink code in Sftp, most importantly add a PathUtils
relativeTo to fixup relative links.
Diffstat (limited to 'libs/sftp/src/main/java')
| -rw-r--r-- | libs/sftp/src/main/java/org/the_jk/cleversync/io/sftp/SftpConnection.kt | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/libs/sftp/src/main/java/org/the_jk/cleversync/io/sftp/SftpConnection.kt b/libs/sftp/src/main/java/org/the_jk/cleversync/io/sftp/SftpConnection.kt index ed5889a..6669e13 100644 --- a/libs/sftp/src/main/java/org/the_jk/cleversync/io/sftp/SftpConnection.kt +++ b/libs/sftp/src/main/java/org/the_jk/cleversync/io/sftp/SftpConnection.kt @@ -50,11 +50,10 @@ internal class SftpConnection(uri: Uri, credentials: SftpCredentials, hostsStora sftpSession?.unlink(PathUtils.join(baseDir, path)) ?: false fun readLink(path: String): String? { - val target = sftpSession?.readlink(PathUtils.join(baseDir, path)) - if (target?.startsWith(baseDir) == true) { - return target.substring(baseDir.length + 1) - } - return target + val linkPath = PathUtils.join(baseDir, path) + val target = sftpSession?.readlink(linkPath) ?: return null + val parentPath = PathUtils.dirname(linkPath) + return PathUtils.relativeTo(parentPath, target) } fun symlink(target: String, rawTarget: Boolean, path: String): Boolean { |
