You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Thomas Neidhart (JIRA)" <ji...@apache.org> on 2015/12/11 23:20:47 UTC
[jira] [Commented] (VFS-393) The ls command allways returns the
cached data
[ https://issues.apache.org/jira/browse/VFS-393?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15053682#comment-15053682 ]
Thomas Neidhart commented on VFS-393:
-------------------------------------
This can indeed happen as the list of children are cached for a LocalFile implementation. A simple testcase illustrating the issue can be seen below:
{code}
// Locate file by absolute file name
final String fileName = new File("testdir").getAbsolutePath();
final FileSystemManager mgr = VFS.getManager();
final FileObject dir = mgr.resolveFile(fileName);
dir.createFolder();
FileObject child = dir.resolveFile("abc");
child.createFile();
System.out.println("first");
FileObject[] children = dir.getChildren();
for (FileObject c : children) {
System.out.println(c.getName());
}
new File("testdir/abc").delete();
//child.delete();
System.out.println("again");
children = dir.getChildren();
for (FileObject c : children) {
System.out.println(c.getName());
}
{code}
in this case, the created file "testdir/abc" is deleted again via the standard java API, thus the VFS object does not get noticed about the change and returns the cached list of children.
Now this can happen also when the file is removed from the filesystem by other means, so in this case you can do two things:
* use a file monitor to listen for changes in the directory
* release the cache resource of the file object before accessing the list of children via file.close()
> The ls command allways returns the cached data
> ----------------------------------------------
>
> Key: VFS-393
> URL: https://issues.apache.org/jira/browse/VFS-393
> Project: Commons VFS
> Issue Type: Bug
> Affects Versions: 2.0
> Environment: Red hat Linux
> Reporter: Prasad Kulkarni
> Priority: Minor
> Labels: patch
>
> We have follwed the below steps to reproduce the issue
> 1. Created a folder under /home/xyz with name abc
> 2. Tried to get the Childrens of /home/xyz
> 3. I have got the folder listed as 'abc' although there are few other childrens which are not considered and listed
> 4. Deleted the folder 'abc'
> 5. Tried to get the Childrens of /home/xyz
> 6. It is still listing the folder 'abc'
> We have also tried all three possible cache strategy but no luck.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)