{"action":"opened","issue":{"url":"https://api.github.com/repos/jborza/camel-smbj/issues/12","repository_url":"https://api.github.com/repos/jborza/camel-smbj","labels_url":"https://api.github.com/repos/jborza/camel-smbj/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/jborza/camel-smbj/issues/12/comments","events_url":"https://api.github.com/repos/jborza/camel-smbj/issues/12/events","html_url":"https://github.com/jborza/camel-smbj/issues/12","id":341522482,"node_id":"MDU6SXNzdWUzNDE1MjI0ODI=","number":12,"title":"moveFailed fails on share.deleteFile()","user":{"login":"MarkBoers92","id":26073317,"node_id":"MDQ6VXNlcjI2MDczMzE3","avatar_url":"https://avatars2.githubusercontent.com/u/26073317?v=4","gravatar_id":"","url":"https://api.github.com/users/MarkBoers92","html_url":"https://github.com/MarkBoers92","followers_url":"https://api.github.com/users/MarkBoers92/followers","following_url":"https://api.github.com/users/MarkBoers92/following{/other_user}","gists_url":"https://api.github.com/users/MarkBoers92/gists{/gist_id}","starred_url":"https://api.github.com/users/MarkBoers92/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MarkBoers92/subscriptions","organizations_url":"https://api.github.com/users/MarkBoers92/orgs","repos_url":"https://api.github.com/users/MarkBoers92/repos","events_url":"https://api.github.com/users/MarkBoers92/events{/privacy}","received_events_url":"https://api.github.com/users/MarkBoers92/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-07-16T13:37:50Z","updated_at":"2018-07-16T13:37:50Z","closed_at":null,"author_association":"NONE","body":"In the case of using a camel route that includes move and moveFailed in the URI the default behaviour is to first delete a file of the same name if present in the target folder.\r\n\r\n**org.apache.camel.component.file.strategy.GenericFileProcessStrategySupport**\r\n```java\r\nprotected GenericFile<T> renameFile(GenericFileOperations<T> operations, GenericFile<T> from, GenericFile<T> to) throws IOException {\r\n        // deleting any existing files before renaming\r\n        try {\r\n            operations.deleteFile(to.getAbsoluteFilePath());\r\n        } catch (GenericFileOperationFailedException e) {\r\n            // ignore the file does not exists\r\n        }\r\n        //Some other unrelated stuff....\r\n}\r\n```\r\nThe provided SmbOperations then is charged with handling the deletion of the file. When it comes to the SmbShare deleteFile(String path) method it fails with STATUS_OBJECT_NAME_NOT_FOUND resulting in an SMBApiException. This is not caught and interrupts the running task. After a lot of debugging I found out that this is intended to delete a file in the provided moveFailed folder with the same name as the file to be moved.\r\n\r\nIn the case of the File component that this library is replacing a check is executed before trying to delete the file. This seems logical to me as the file is to be moved and this prevents naming conflicts but there might be nothing there.\r\n\r\n**org.apache.camel.util.FileUtil**\r\n```java\r\npublic static boolean deleteFile(File file) {\r\n        // do not try to delete non existing files\r\n        if (!file.exists()) {\r\n            return false;\r\n        }\r\n        //Some other stuff....\r\n}\r\n```\r\nAs far as I can see this check is not happening when using this library resulting in the STATUS_OBJECT_NAME_NOT_FOUND error due to the file not actually existing in that location (yet).\r\n\r\nMy suggestion would be to use the fileExists method already provided on the SmbShare class as a check before calling share.rm(path). Catching the SMBApiException seems too generic to me as it might relate to other issues with the share/client. What do you think? I'm currently implementing this fix for an application we use. I have to say that your library works great otherwise. Very easy to use. :smile: "}}
{"actor":{"display_login":"MarkBoers92"}}