[Yanel-dev] virtual file system node does not get deleted
Michael Wechner
michael.wechner at wyona.com
Sat Mar 1 15:51:44 CET 2008
Evaldas Taroza wrote:
> Hi,
> I use VirtualFileSystemRepository in the project. I have a Node which
> I want to delete, so I call:
>
> node.delete();
>
> but it is not deleted... I looked into the implementation, and for me
> it seems to have some bugs (although in my case it should have worked)
>
> LINE 430:
> ------
> public void delete() throws RepositoryException {
> deleteRec(this);
> }
>
> protected void deleteRec(Node node) throws RepositoryException {
> Node[] children = node.getNodes();
> for (int i=0; i<children.length; i++) {
> deleteRec(children[i]);
> }
> try {
> if (getRepository().getMap().isCollection(new Path(getPath()))) {
> FileUtils.deleteDirectory(this.contentFile);
> } else {
> this.contentFile.delete();
> }
> FileUtils.deleteDirectory(this.metaDir);
> } catch (IOException e) {
> throw new RepositoryException("Could not delete node: " +
> node.getPath() + ": " + e.toString(), e);
> }
> }
> ----
> So the problems I see in this code is that the deleteRec recursively
> is deleting the same file - this.contentFile. Everywhere this method
> should refer to "node":
> node.getPath()
> node.contentFile.delete()
> node.metaDir
>
> However, I was deleting one file only, so recursion is of the depth 0
> and therefore this.contentFile.delete() should have worked. But
> apparently the file is still there, and no exceptions thrown. Indeed,
> if you look at
> http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html#delete()
> it is never throwing a IOException on failure.
>
> The file which is not deleted is most likely used by the browser, and
> therefore is locked.
Linux/Unix does not lock files
> So how to deal with such cases?
I think the VFS implementation should check after deleting if it has
really been deleted and if not, then through an exception itself (for
example the message could be: Node could not be deleted, because it
might be used by some other application).
Makes sense?
Could you provide a patch?
Thanks
Michi
>
> Evaldas
>
--
Michael Wechner
Wyona - Open Source Content Management - Yanel, Yulup
http://www.wyona.com
michael.wechner at wyona.com, michi at apache.org
+41 44 272 91 61
More information about the Yanel-development
mailing list