Changeset 5997


Ignore:
Timestamp:
Aug 26, 2020, 9:54:06 AM (15 months ago)
Author:
Nicklas Nordborg
Message:

Fixes #1264: The OpenGridSession?.getJobFileAsString() should return null when the requested file doesn't exists

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.opengrid/trunk/src/net/sf/basedb/opengrid/AbstractSession.java

    r5984 r5997  
    2222import net.schmizz.sshj.sftp.OpenMode;
    2323import net.schmizz.sshj.sftp.RemoteFile;
     24import net.schmizz.sshj.sftp.Response;
    2425import net.schmizz.sshj.sftp.SFTPClient;
     26import net.schmizz.sshj.sftp.SFTPException;
    2527import net.schmizz.sshj.xfer.LocalFileFilter;
    2628import net.schmizz.sshj.xfer.LocalSourceFile;
     
    276278    {
    277279      in = getRemoteInputStream(fromPath, target.getMetadata());
    278       out = target.getOutputStream();
    279       FileUtil.copy(in, out);
    280      
    281       if (logger.isDebugEnabled())
    282       {
    283         logger.debug("File '" + target.getName() + "' downloaded from " + remote + ": " + fromPath);
     280      if (in != null)
     281      {
     282        out = target.getOutputStream();
     283        FileUtil.copy(in, out);
     284        if (logger.isDebugEnabled())
     285        {
     286          logger.debug("File '" + target.getName() + "' downloaded from " + remote + ": " + fromPath);
     287        }
     288      }
     289      else
     290      {
     291        if (logger.isDebugEnabled())
     292        {
     293          logger.debug("File doesn't exists: " + fromPath);
     294        }
    284295      }
    285296    }
     
    329340  {
    330341    getSFTPClient();
    331     RemoteFile rf = sftp.open(fromPath, EnumSet.of(OpenMode.READ));
     342    RemoteFile rf = null;
     343    try
     344    {
     345      rf = sftp.open(fromPath, EnumSet.of(OpenMode.READ));
     346    }
     347    catch (SFTPException ex)
     348    {
     349      if (ex.getStatusCode() == Response.StatusCode.NO_SUCH_FILE) return null;
     350      throw ex;
     351    }
    332352   
    333353    if (metadata != null)
Note: See TracChangeset for help on using the changeset viewer.