commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jared Graber" <jgra...@zedak.com>
Subject [vfs]sFTP Imaginary Directory Type
Date Fri, 17 Mar 2006 19:29:37 GMT
Hi,

 

I've been using VFS (with the JSch library) to connect to an SFTP server.
Today we encountered an interesting problem that unfortunately I haven't
been able to duplicate yet.

 

One of our requirements is to get the name of all the files in a folder w/ a
specific extension.

 

This part of the app is part of a daemon thread and is called pretty often.

Here is the code:

 

                        FileSystemManager fileSystemManager = null;

                        FileObject directory = null;

                        TagFileListing tags;

                        try {

                                    fileSystemManager = VFS.getManager();

                                    directory =
fileSystemManager.resolveFile(this.getFileLocationURI());

                                    if (LOG.isDebugEnabled())
LOG.debug("File location: '" + this.getFileLocationURI() + "'");

                                    FileSelector tagFileSelector = new
FileExtensionSelector(".tag");

                                    if (LOG.isDebugEnabled())
LOG.debug("Directory Path: " + directory.getName().getPath());

                                    if (LOG.isDebugEnabled())
LOG.debug("Directory Type: " + directory.getType().getName());

 

                                    FileObject [] tagFiles =
directory.findFiles(tagFileSelector);

                                    tags = new TagFileListing();

                                    if (tagFiles != null) {

                                                if (LOG.isDebugEnabled())
LOG.debug("Tag files found:\t" + tagFiles.length);

                                                for (int i = 0; i <
tagFiles.length; i++) {

                                                            FileObject
tagFile = tagFiles[i];

                                                            String tagName =
tagFile.getName().getBaseName();

                                                            if
(LOG.isDebugEnabled()) LOG.debug("Found tag file: '" + tagName + "'");

 
tags.addTagFile(tagName);

                                                }

                                    }

                                    else {

                                                if (LOG.isDebugEnabled())
LOG.debug("No tag files found");

                                    }

                                    return tags;

                        } finally {

                                    if (directory != null)
directory.close();

                                    if (fileSystemManager != null)
fileSystemManager.getFilesCache().close();

                        }

 

 

I'm thinking that the problem is that the type for the FileObject directory
is FileType.Imaginary or I'm not using the provided caching correctly. 

No FileObjects are (incorrectly) returned by
directory.findFile(tagFileSelector)

 

If we restart the application, the type of 'directory' is FOLDER (which is
expected) and a correct set of FileObjects is returned by the findFiles
method.

The value of this.getFileLocationURI()  did not change when we restarted the
app (it originates from configuration parameters).

 

Any ideas as to what went wrong?

 

-Jared


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message