Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: [FTPFileSystem] Path argument for TFTPFileSystem::DoChangeDirectory is Filename instead of Directory

The problem is not the CWD, the problem is that the server fails the MDTM with "No such file or directory". Why, if the file exists?
williams4411

[FTPFileSystem] Path argument for TFTPFileSystem::DoChangeDirectory is Filename instead of Directory

Error observed in WinSCP versions 575 and 576

Protocol Type: FTP
Server Type: AVM Fritz!Box Router Models (7170, 7050, 7360, 7490) all updated

Operation: Scripted getFiles(/Intenso-AluLine-01/folder/file.json)
File is present and can be transferred using the GUI

Operation section: STAT command
Normal behavior: STAT command, GET command

Session log snippet:
Script: stat -- "/Intenso-AluLine-01/folder/file.json"

Listing file "/Intenso-AluLine-01/folder/file.json".
Retrieving file information...
PWD
257 "/Intenso-AluLine-01/folder" is current directory.
CWD /Intenso-AluLine-01/folder/file.json
550 /Intenso-AluLine-01/folder/file.json: Not a directory.

TYPE I
200 Type set to I.
SIZE /Intenso-AluLine-01/folder/file.json
213 508
MDTM /Intenso-AluLine-01/folder/file.json
550 /Intenso-AluLine-01/folder/file.json: No such file or directory
Could not retrieve file information
Script: Can't get attributes of file '/Intenso-AluLine-01/folder/file.json'.
Script: Could not retrieve file information
/Intenso-AluLine-01/folder/file.json: No such file or directory
Script: Failed

Background information
WinSCP seems to fetch remote file information any time a file is being downloaded
-> This leads to remote directory listing on certain servers

If a script knows that a file is present, would it be possible to disable file information retrieval by configurable boolean property?
-> This could help to reduce amount of transactions for managed remote file systems
-> This would also be a hotfix for the problem I encountered

After brief survey of the source, it seems that DoChangeDirectory is called with the filename as argument instead of the file's directory.

Relevant Function:
void __fastcall TFTPFileSystem::ChangeDirectory(const UnicodeString ADirectory)
{
  UnicodeString Directory = ADirectory;
  try
  {
    // For changing directory, we do not make paths absolute, instead we
    // delegate this to the server, hence we synchronize current working
    // directory with the server and only then we ask for the change with
    // relative path.
    // But if synchronization fails, typically because current working directory
    // no longer exists, we fall back to out own resolution, to give
    // user chance to leave the non-existing directory.
    EnsureLocation();
  }
  catch(...)
  {
    if (FTerminal->Active)
    {
      Directory = AbsolutePath(Directory, false);
    }
    else
    {
      throw;
    }
  }
 
  DoChangeDirectory(Directory);
 
  // make next ReadCurrentDirectory retrieve actual server-side current directory
  FReadCurrentDirectory = true;
}

Hopefully this information can be of some use, WinSCP really is a great software and thanks to the scripting interface it achieves an utmost degree of versatility.
Finally I'd be really thankful if it were possible to implement the property switch spoken of in order to improve efficiency in an automated usage scenario.

With kind regards, Williams4411

On Model 7050
ftp> sys

215 UNIX Type: L8 Version: Linux 2.6.19.2