FTPGETDIFF         Get specific changes within FTP site file system

Top  Previous  Next

Syntax:

FTPGETDIFF

[ dbfile ]

Arguments:

[ dbfile ]

Optional Variable or string specifying a snapshot database file. If omitted, the default value is “snapshot_site.sql”. When [ dbfile ] is specified without a full path the alternate default path is used.

Options:

/commitlast

Mark current difference "done" on the next call to FTPGETDIFF.

 

/incldirs

Allows returning new or deleted directories.

 

 

The FTPDIFF and FTPGETDIFF commands work together to identify and process changes to files on a remote server.

 

The FTPGETDIFF command sets the values of five internal variables with details describing a change to a single file on a remote site. These details are pulled from a snapshot database where they were inserted by a previous call to the FTPDIFF command. Subsequent calls to FTPGETDIFF fetch the details of subsequent changes from the database. The FTPGETDIFF command is typically used in a loop so that each detected change is processed during one iteration of the loop. Depending on your needs, the processing may involve one or more of the internal variables set by this command. It is possible for FTPGETDIFF to report file changes in alphabetical order rather than folder hierarchical order depending on how the records are stored in the snapshot database. This command returns $ERROR_READ_EOF when there are no more differences in the database. The FTPDIFFREWIND command is available to reset the file pointer to the first change recorded in the database.

 

If the [ dbfile ] argument is omitted, the default file name “snapshot_site.sql” file is used. An error occurs if the snapshot database file does not exist.

 

The FTPGETDIFF command sets the values of the following variables that you can use in your script logic:

 

%ftpdifffileid

Type of change detected

%ftpdifffiletext

Text description of type of change detected

%ftpdifffilename

Name of changed file

%ftpdifffilepath

Full path of changed file

%ftpdiffnum

Sequential change number

 

The possible values of %ftpdifffileid and %ftpdifffiletext are:

 

$DIFF_FILE_NOT_FOUND

5001

** File not found

$DIFF_FILE_IS_NEW

5002

** File is new

$DIFF_FILE_SIZE

5003

** File size changed

$DIFF_FILE_DATETTIME

5004

** File date/time stamp changed

With /incldirs:

 

 

$DIFF_DIRECTORY_NOT_FOUND

5005

** File not found

$DIFF_DIRECTORY_IS_NEW

5006

** File is new

 

Here is a simple example that shows how FTPGETDIFF might be used inside a loop to write a text file that lists all the changes found by FTPDIFF:

 

FTPDIFF "*"

:loop

FTPGETDIFF

IFERROR= $ERROR_READ_EOF GOTO done

SET change = "File: " + %ftpdifffilepath + " " + %ftpdifffiletext

WRITEFILE "differences.txt" change /append

GOTO loop

:done

 

The following example loops through all changes and downloads only the new files from a remote site:

 

FTPDIFF "*"

:loop

FTPGETDIFF

IFERROR= $ERROR_READ_EOF GOTO done

IFNUM!= %ftpdifffileid $DIFF_FILE_IS_NEW GOTO loop

RCVFILE %ftpdifffilename

GOTO loop

:done

 

If you need to restart the loop, use the FTPDIFFREWIND command to reset the file pointer to the first difference recorded in the snapshot database.

 

Normally, all current differences are marked "done" when FTPDIFF is called again. The /commitlast option increases fault tolerance by causing FTPGETDIFF to mark the previously retrieved difference done. This way, a difference should not be processed twice if loop processing is interrupted after FTPGETDIFF is called but before the full loop iteration is complete.

 

Note: Snapshot database files are small SQLite database files created by Robo-FTP to support the DIFF and FTPDIFF family of script commands.

 

Important

The success of this command depends on Robo-FTP's ability to automatically read and understand the directory listings returned by the remote site. Most HTTP/HTTPS sites do not return listings in a supported format and many return no raw directory listings in response to HTTP GET requests based on slash-terminated URLs. Some servers respond to HEAD requests and are partially compatible. Some supported HTTP listing types like APACHE_DEFAULT include file sizes rounded to the nearest megabyte or kilobyte and are therefore not fully compatible with this command. Contact technical support if you have an urgent need related to a raw directory listing format that is currently unsupported.

 

 

Related command(s): FTPDIFF, FTPDIFFREWIND, GETDIFF

See also: Processing Dynamic Folders, Using the built-in database engine, Alternate Default Path