[jcifs] "Could not delete file" warning when moving

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[jcifs] "Could not delete file" warning when moving

dreske
Hello,

I have another issue with the "could not delete" warning.

If the GenericFileProcessStrategySupport is going to rename file A to B, it tries to delete B before.
But if B does not exist (which is default, because we want to rename A to B), the DefaultSmbClient  logs the warning message.

This is quite annoying, because so we get a lot of false warning messages (we are processing thousand of files each hour).

Till I don't have a good idea, how to solve this issue.
Perhaps the the GenericFileProcessStrategySupport should not try to delete the file, because the GenericFileOperations interface has its own renameFile (which is used after deleting), where the concrete implementation should ensure that the target file is deleted before (as camel-jcifs does). But this would be an issue for the camle-core team. (Edit: and it would also change existing behavior)

Another solution could be to pass a suppressWarnings flag to the delete operation, but imo this is also quite ugly.

Edit:
One solution could be just to check if the target file exists, before deleting. This could be done in DefaultSmbClient OR in GenericFileOperations

Thanks
Dirk
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [jcifs] "Could not delete file" warning when moving

Pontus Ullgren
I agree with your last suggested solution. It would also allow us to fix this in camel-jcifs without the need to involve the camel-core team.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [jcifs] "Could not delete file" warning when moving

dreske
This post was updated on .
The only drawback of this is, it would increase network load.
I think an smbFile.exists() call will make a smb request to the server.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [jcifs] "Could not delete file" warning when moving

Pontus Ullgren
No there will not be that much overhead due to the way jcifs API work internally.

Right now the call to smbFile.delete() will fetch file attributes before issue the delete command.
However if we add the call to smbFile.exists() it will fetch the file attributes and cache them.
The subsequent call to smbFile.delete() will then just use the cached attributes.

See the code of SmbFiles especially the delete() and exists() methods.
https://jcifs.samba.org/src/src/jcifs/smb/SmbFile.java

Best regards
// Pontus
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [jcifs] "Could not delete file" warning when moving

Pontus Ullgren
This has now been fixed in master branch and should be included in the upcoming 2.14.0 release.
Loading...