> But sometimes, after the sync, I see that dirs which do not exist on the
> share are not deleted on the local file system. Instead, just the files in
> the dirs are deleted.
> I still have not been able to track down when exactly it happens.
> it works as it should (i.e. the dir is deleted), but sometimes it does
Since you mentioned Windows, it is likely that the OS may still have a
"lock" on the directory, so any delete operation will fail.
Windows does not allow one to delete a file if there is a process that has
an open handle to it, and if a directory, an open handle to a file within
it. I believe there are race conditions within Windows on when a process
closes a handle and when Windows actually releases the handle. This could
be what is happening. If you have AV software running, it could be a
Without examining the source of the sync task itself, unknown if operation
order can be modified to minimize the problem. I do not know if the sync
task checks if file deletions actually succeed. It is common for Java
programs to not check the return value of a delete operation (File#delete())
to verify it actually worked.
> Windows does not allow one to delete a file if there is a process that has
> an open handle to it
Thank you for the hint! I'll check whether the dir is locked by a process.
> I do not know if the sync
> task checks if file deletions actually succeed. It is common for Java
> programs to not check the return value of a delete operation (File#delete())
> to verify it actually worked.
The desired result here would be that the dir 'aaa' is deleted in the target because the dir does not exist in the source.
What I observe is that the dir 'aaa' is not deleted because it contains a file to preserve. But this file should be ignored in my case because 'aaa' should be deleted as a whole. I.e. ant should not even look into aaa.
How can I achieve this?
To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email]
> When synchronizing the dirs, we'd like to preserve some files. These files
> have a certain local name. Hence we specify these files in the
> 'preserveintarget' clause.
> [...] What I observe is that the dir 'aaa' is not deleted because it
> contains a file to preserve. But this file should be ignored in my case
> because 'aaa' should be deleted as a whole. I.e. ant should not even look
> into aaa.
> How can I achieve this?
You can't. <preserveintarget> "wins" indeed, by design, as the task is
You'd need to add a (e.g.) "unlessAncestorDirIsRemoved" attribute on
<preserveintarget>, with associated logic of course.
Or you work around by copying/syncing your "preserved" files in to a 3rd
Sync as before, w/o the <preserveintarget> elements.
And "restore" those back, provided their directory still exists. I think
it's possible with a selector
and mapper to figure out of the "preserved" files should be restored (not
easy, but possible).