Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 69D9C200C38 for ; Wed, 15 Mar 2017 20:31:47 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 689F8160B60; Wed, 15 Mar 2017 19:31:47 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id A65EF160B7C for ; Wed, 15 Mar 2017 20:31:46 +0100 (CET) Received: (qmail 69564 invoked by uid 500); 15 Mar 2017 19:31:44 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 69552 invoked by uid 99); 15 Mar 2017 19:31:44 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Mar 2017 19:31:44 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id A6456180BB2 for ; Wed, 15 Mar 2017 19:31:43 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.451 X-Spam-Level: * X-Spam-Status: No, score=1.451 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_NEUTRAL=0.652] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id 51oTNTwyaB2s for ; Wed, 15 Mar 2017 19:31:42 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 7CC035F295 for ; Wed, 15 Mar 2017 19:31:42 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id DB5E5E087E for ; Wed, 15 Mar 2017 19:31:41 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 9758C243AC for ; Wed, 15 Mar 2017 19:31:41 +0000 (UTC) Date: Wed, 15 Mar 2017 19:31:41 +0000 (UTC) From: "Shon Vella (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (VFS-620) FileObject.moveTo(FileObject) API doesn't work well for a Linux FTP MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Wed, 15 Mar 2017 19:31:47 -0000 [ https://issues.apache.org/jira/browse/VFS-620?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Shon Vella updated VFS-620: --------------------------- Attachment: VFS-620c.patch Sorry - I guess that what I get for trying to copy and paste the changes into the existing patch instead of doing a new diff from the sources that are working for me. Updated patch uploaded. > FileObject.moveTo(FileObject) API doesn't work well for a Linux FTP > ------------------------------------------------------------------- > > Key: VFS-620 > URL: https://issues.apache.org/jira/browse/VFS-620 > Project: Commons VFS > Issue Type: Bug > Affects Versions: 2.1 > Environment: ubuntu vsftpd > Reporter: stevezhuang > Attachments: VFS-620c.patch > > > FileObject.moveTo(FileObject) API doesn't work well for a Linux FTP, especially for setting a user directory as its root directory case, > For example, for a ubuntu vsftpd, which is having "/home/user1" as its root directory, when renaming "/test/test.txt" to "/test1/test1.txt", it will throw an exception. > In this case, it should consider the workingDirectory(would be "/home/user1") together and append it to the from/to path to make the API work. > Sample codes, > FileObject fileObject = null; > FileObject toFileObject = null; > try { > StandardFileSystemManager fsManager = new StandardFileSystemManager(); > fsManager.init(); > FileSystemOptions fsOpts = new FileSystemOptions(); > FtpFileSystemConfigBuilder.getInstance().setPassiveMode(fsOpts, true); > FtpFileSystemConfigBuilder.getInstance().setUserDirIsRoot(fsOpts, true); > UserAuthenticator auth = new StaticUserAuthenticator(null, "", ""); > DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(fsOpts, auth); > fileObject = fsManager.resolveFile("ftp:///test/test.txt", fsOpts); > System.out.println("File exists:" + fileObject.exists()); > toFileObject = fsManager.resolveFile("ftp:///test1/test1.txt", fsOpts); > System.out.println("File exists:" + toFileObject.exists()); > if (!toFileObject.exists()) { > toFileObject.createFile(); > } > fileObject.moveTo(toFileObject); > } catch (FileSystemException ex) { > ex.printStackTrace(); > } finally { > if (fileObject != null) { > try { > fileObject.close(); > } catch (FileSystemException ex) { > } > } > if (toFileObject != null) { > try { > toFileObject.close(); > } catch (FileSystemException ex) { > } > } > } > And the output, > File exists:true > File exists:false > org.apache.commons.vfs2.FileSystemException: Could not rename "ftp:///test/test.txt" to "ftp:///test1/test1.txt". > at org.apache.commons.vfs2.provider.AbstractFileObject.moveTo(AbstractFileObject.java:1902) > at TestFTP.main(TestFTP.java:59) > Caused by: org.apache.commons.vfs2.FileSystemException: Could not rename FTP file "ftp:///test/test.txt" to "ftp:///test1/test1.txt". > at org.apache.commons.vfs2.provider.ftp.FtpFileObject.doRename(FtpFileObject.java:524) > at org.apache.commons.vfs2.provider.AbstractFileObject.moveTo(AbstractFileObject.java:1887) -- This message was sent by Atlassian JIRA (v6.3.15#6346)