Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to rename remote file due to permission failure #40

Open
sakama opened this issue Dec 21, 2017 · 1 comment
Open

Failed to rename remote file due to permission failure #40

sakama opened this issue Dec 21, 2017 · 1 comment

Comments

@sakama
Copy link
Contributor

sakama commented Dec 21, 2017

I changed upload logic at #37 before.
In this change, plugin will create temporary file at remote SFTP server and rename it after all task completed since plugin user can't know if task was finished or not when some of tasks failed.

However, this change sometimes got permission failure while renaming remote file.

SFTP rename remote file failed. Retrying 1/10 after 0 seconds. Message: Could not determine if file sftp://***/path/to/somewhere is writeable. 

I don't know why file rename failed even if plugin is able to upload temporary file.
Anyway, we need to improve upload logic.

@sakama
Copy link
Contributor Author

sakama commented Mar 9, 2018

I found the cause.

Apache Commons VFS2 is checking parent directory's permission before renaming remote files on SFTP server.

    @Override
    public void moveTo(final FileObject destFile) throws FileSystemException {
        if (canRenameTo(destFile)) {
            if (!getParent().isWriteable()) {
                throw new FileSystemException("vfs.provider/rename-parent-read-only.error", getName(),
                        getParent().getName());
            }
        } else {
            if (!isWriteable()) {
                throw new FileSystemException("vfs.provider/rename-read-only.error", getName());
            }
        }
        ...

https://github.com/apache/commons-vfs/blob/commons-vfs2-2.2-rc1/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractFileObject.java#L1572-L1581

This works if SFTP account has permission to exec command over SSH.
However, doesn't work if SSH command isn't permitted.

Same problems were already reported at JIRA.
https://issues.apache.org/jira/browse/VFS-590

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant