-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3888 from TranceLove/bugfix/ssh-copy-fixes-2
Bugfix/ssh copy fixes 2
- Loading branch information
Showing
13 changed files
with
420 additions
and
339 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
190 changes: 97 additions & 93 deletions
190
app/src/main/java/com/amaze/filemanager/filesystem/HybridFile.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
app/src/main/java/com/amaze/filemanager/filesystem/ssh/SFTPClientExt.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright (C) 2014-2023 Arpit Khurana <[email protected]>, Vishal Nehra <[email protected]>, | ||
* Emmanuel Messulam<[email protected]>, Raymond Lai <airwave209gt at gmail.com> and Contributors. | ||
* | ||
* This file is part of Amaze File Manager. | ||
* | ||
* Amaze File Manager is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.amaze.filemanager.filesystem.ssh | ||
|
||
import net.schmizz.sshj.sftp.FileAttributes | ||
import net.schmizz.sshj.sftp.OpenMode | ||
import net.schmizz.sshj.sftp.PacketType | ||
import net.schmizz.sshj.sftp.RemoteFile | ||
import net.schmizz.sshj.sftp.SFTPClient | ||
import net.schmizz.sshj.sftp.SFTPEngine | ||
import java.io.IOException | ||
import java.util.EnumSet | ||
import java.util.concurrent.TimeUnit | ||
|
||
const val READ_AHEAD_MAX_UNCONFIRMED_READS: Int = 16 | ||
|
||
/** | ||
* Monkey-patch [SFTPEngine.open] until sshj adds back read ahead support in [RemoteFile]. | ||
*/ | ||
@Throws(IOException::class) | ||
fun SFTPEngine.openWithReadAheadSupport( | ||
path: String, | ||
modes: Set<OpenMode>, | ||
fa: FileAttributes | ||
): RemoteFile { | ||
val handle: ByteArray = request( | ||
newRequest(PacketType.OPEN).putString(path, subsystem.remoteCharset) | ||
.putUInt32(OpenMode.toMask(modes).toLong()).putFileAttributes(fa) | ||
).retrieve(timeoutMs.toLong(), TimeUnit.MILLISECONDS) | ||
.ensurePacketTypeIs(PacketType.HANDLE).readBytes() | ||
return RemoteFile(this, path, handle) | ||
} | ||
|
||
/** | ||
* Monkey-patch [SFTPClient.open] until sshj adds back read ahead support in [RemoteFile]. | ||
*/ | ||
fun SFTPClient.openWithReadAheadSupport(path: String): RemoteFile { | ||
return sftpEngine.openWithReadAheadSupport( | ||
path, | ||
EnumSet.of(OpenMode.READ), | ||
FileAttributes.EMPTY | ||
) | ||
} |
Oops, something went wrong.