[
https://issues.apache.org/jira/browse/SSHD-929?focusedWorklogId=266892&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-266892
]
ASF GitHub Bot logged work on SSHD-929:
---------------------------------------
Author: ASF GitHub Bot
Created on: 25/Jun/19 17:59
Start Date: 25/Jun/19 17:59
Worklog Time Spent: 10m
Work Description: lgoldstein commented on pull request #104: [SSHD-929]
Create separate listener for remove directory.
URL: https://github.com/apache/mina-sshd/pull/104#discussion_r297317727
##########
File path:
sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/AbstractSftpSubsystemHelper.java
##########
@@ -1527,17 +1527,36 @@ protected void doRemoveDirectory(int id, String path,
LinkOption... options) thr
* @param p {@link Path} to delete
* @throws IOException If failed to delete
*/
- protected void doRemove(int id, Path p) throws IOException {
+ protected void doRemove(int id, Path p, boolean isDirectory) throws
IOException {
SftpEventListener listener = getSftpEventListenerProxy();
ServerSession session = getServerSession();
- listener.removing(session, p);
+
+ signalRemoving(p, listener, session, isDirectory);
try {
Files.delete(p);
} catch (IOException | RuntimeException e) {
- listener.removed(session, p, e);
+ signalRemoved(p, listener, session, isDirectory, e);
throw e;
}
- listener.removed(session, p, null);
+ signalRemoved(p, listener, session, isDirectory, null);
+ }
+
+ private void signalRemoving(Path p, SftpEventListener listener,
ServerSession session,
+ boolean isDirectory) throws IOException {
+ if (isDirectory) {
+ listener.removingDirectory(session, p);
+ } else {
+ listener.removingFile(session, p);
+ }
+ }
+
+ private void signalRemoved(Path p, SftpEventListener listener,
ServerSession session,
Review comment:
protected please - we always try to allow users to override any behavior
they like
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 266892)
Time Spent: 50m (was: 40m)
> Separate listener for deleting directory in SFTP
> ------------------------------------------------
>
> Key: SSHD-929
> URL: https://issues.apache.org/jira/browse/SSHD-929
> Project: MINA SSHD
> Issue Type: Improvement
> Affects Versions: 2.3.0
> Reporter: Subramaniajeeva
> Assignee: Goldstein Lyor
> Priority: Minor
> Time Spent: 50m
> Remaining Estimate: 0h
>
> Right now listener for deletion of file and directory is common. This makes
> it difficult to find whether directory / file has been removed.
> The path passed to `removed` function in SftpEventListener will not tell if
> the deleted path was a directory or file. `Files.isDirectory(path)` will
> return false, as the derectory doesn't exist.
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]