[ 
https://issues.apache.org/jira/browse/SSHD-118?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Otto Frost updated SSHD-118:
----------------------------

    Description: 
I logon, and then 
put xx xx
rename xx yy

O1706@WKE198515 ~
$ sftp -oport=2222 a@localhost
Connecting to localhost...
a@localhost's password:
sftp> cd tmp
sftp> put xx
Uploading xx to /C:/NWDS7.1EHP1/workspace/minasshd_custom/tmp/xx
xx                                            100% 1039     1.0KB/s   00:00
sftp> rename xx yy
Couldn't rename file "/C:/NWDS7.1EHP1/workspace/minasshd_custom/tmp/xx" to "/C:/
NWDS7.1EHP1/workspace/minasshd_custom/tmp/yy": Failure
sftp>


The problem is that the file isn't closed after uploading, 
SftpSubSystem.process SSH_FXP_WRITE
NativeSshFile.createOutputStream doesn't close the file, even though the close 
method is called.

I can't rename the file from the os either because mina sshd holds it locked 
after upload. When mina sshd is shut down I can rename the file. After 
restarting minasshd the file can be renamed (from mina sshd or from the os).

Here is the correction:
class NativeSshFile
        public void truncate() throws IOException {
                // e.on modification
                // permission check
                // and close the raf
                if (!isWritable()) {
                        throw new IOException("No write permission : " + 
file.getName());
                }
                RandomAccessFile raf = new RandomAccessFile(file, "rw");
                boolean bIOExcpetion = false;
                IOException ioException = null;
                if (raf != null) {
                        try {
                                raf.setLength(0);
                        } catch (IOException e) {
                                e.printStackTrace();
                                ioException = e;
                                bIOExcpetion = true;
                        } finally {
                                if (raf != null)
                                        raf.close();
                        }
                }
                if (bIOExcpetion)
                        throw ioException;
        }


  was:
I logon, and then 
put xx xx
rename xx yy

O1706@WKE198515 ~
$ sftp -oport=2222 a@localhost
Connecting to localhost...
a@localhost's password:
sftp> cd tmp
sftp> put xx
Uploading xx to /C:/NWDS7.1EHP1/workspace/minasshd_custom/tmp/xx
xx                                            100% 1039     1.0KB/s   00:00
sftp> rename xx yy
Couldn't rename file "/C:/NWDS7.1EHP1/workspace/minasshd_custom/tmp/xx" to "/C:/
NWDS7.1EHP1/workspace/minasshd_custom/tmp/yy": Failure
sftp>


The problem is that the file isn't closed after uploading, 
SftpSubSystem.process SSH_FXP_WRITE
NativeSshFile.createOutputStream doesn't close the file, even though the close 
method is called.

I can't rename the file from the os either because mina sshd holds it locked 
after upload. When mina sshd is shut down I can rename the file. After 
restarting minasshd the file can be renamed (from mina sshd or from the os).

Here is the correction:
class NativeSshFile
        public void truncate() throws IOException {
                // modification
                // permission check
                // and close the raf
                if (!isWritable()) {
                        throw new IOException("No write permission : " + 
file.getName());
                }
                RandomAccessFile raf = new RandomAccessFile(file, "rw");
                if (raf != null) {
                        raf.setLength(0);
                        raf.close();
                }
        }



> uploading and then renaming a file doesn't work (on windows)
> ------------------------------------------------------------
>
>                 Key: SSHD-118
>                 URL: https://issues.apache.org/jira/browse/SSHD-118
>             Project: MINA SSHD
>          Issue Type: Bug
>    Affects Versions: 0.5.0
>         Environment: windows xp professional sun jdk 1.5.0.22, jre 1.6
> windows 2003 server SP2 sun jdk jre 1.5.0.22
>            Reporter: Otto Frost
>            Priority: Critical
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> I logon, and then 
> put xx xx
> rename xx yy
> O1706@WKE198515 ~
> $ sftp -oport=2222 a@localhost
> Connecting to localhost...
> a@localhost's password:
> sftp> cd tmp
> sftp> put xx
> Uploading xx to /C:/NWDS7.1EHP1/workspace/minasshd_custom/tmp/xx
> xx                                            100% 1039     1.0KB/s   00:00
> sftp> rename xx yy
> Couldn't rename file "/C:/NWDS7.1EHP1/workspace/minasshd_custom/tmp/xx" to 
> "/C:/
> NWDS7.1EHP1/workspace/minasshd_custom/tmp/yy": Failure
> sftp>
> The problem is that the file isn't closed after uploading, 
> SftpSubSystem.process SSH_FXP_WRITE
> NativeSshFile.createOutputStream doesn't close the file, even though the 
> close method is called.
> I can't rename the file from the os either because mina sshd holds it locked 
> after upload. When mina sshd is shut down I can rename the file. After 
> restarting minasshd the file can be renamed (from mina sshd or from the os).
> Here is the correction:
> class NativeSshFile
>       public void truncate() throws IOException {
>               // e.on modification
>               // permission check
>               // and close the raf
>               if (!isWritable()) {
>                       throw new IOException("No write permission : " + 
> file.getName());
>               }
>               RandomAccessFile raf = new RandomAccessFile(file, "rw");
>               boolean bIOExcpetion = false;
>               IOException ioException = null;
>               if (raf != null) {
>                       try {
>                               raf.setLength(0);
>                       } catch (IOException e) {
>                               e.printStackTrace();
>                               ioException = e;
>                               bIOExcpetion = true;
>                       } finally {
>                               if (raf != null)
>                                       raf.close();
>                       }
>               }
>               if (bIOExcpetion)
>                       throw ioException;
>       }

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to