They work fine for profiles where one side is FTP or Google Drive.
But these hooks are not called if both sides are local Windows folders.
Is there any generic hook available for all sync types - local ore remote destination ?
Something like 'OnFileSynced'
My aim is to log all successfully synced files to a Sqlite database file.
Whoever is interested, here is my PascalScript:
Code: Select all
const
pathSqlite = 'c:\Program Files\sqlite\sqlite3.exe';
pathDatabase = 'c:\appdata\Syncovery\syncovery_log.sqlite3';
function BoolToStr(const b: Boolean): UnicodeString;
begin
if b then
Result := 'true'
else
Result := 'false';
end;
{
If 'is_right_side' is true (=1) then
the remote machine (FTP or Google Drive) is on the RIGHT-hand side of the Syncovery profile.
If 'is_right_side' is false(=0) then the remote computer is on the LEFT-hand side of the profile.
}
function OnUploadComplete(const FileName, LocalFilePath, CompleteURL: UnicodeString; const isRightSide:Boolean; const FileSize:Int64; const Connector: Opaque):Boolean;
var
sql : UnicodeString;
cmd : UnicodeString;
begin
sql := 'insert into log ( syncovery_hook, profile_name, file_name, file_size, local_file_path, complete_url, is_right_side) ' +
'values (''OnUploadComplete'', ''' + ProfileName + ''', ''' + FileName + ''', ' + IntToStr(FileSize) + ', ''' + LocalFilePath + ''', ''' + CompleteURL + ''', ' + BoolToStr(isRightSide) + ')';
cmd := pathSqlite + ' ' + pathDatabase + ' "' + sql + '"';
Execute(cmd, 100);
Log(BoolToStr(isRightSide));
Result:=true;
end;
function OnDownloadComplete(const FileName, LocalFilePath, CompleteURL: UnicodeString; const isRightSide:Boolean; const FileSize:Int64; const Connector: Opaque):Boolean;
var
sql : UnicodeString;
cmd : UnicodeString;
begin
sql := 'insert into log (syncovery_hook, profile_name, file_name, file_size, local_file_path, complete_url, is_right_side) ' +
'values (''OnDownloadComplete'', ''' + ProfileName + ''', ''' + FileName + ''', ' + IntToStr(FileSize) + ', ''' + LocalFilePath + ''', ''' + CompleteURL + ''', ' + BoolToStr(isRightSide) + ')';
cmd := pathSqlite + ' ' + pathDatabase + ' "' + sql + '"';
Execute(cmd, 100);
Log(BoolToStr(isRightSide));
Result:=true;
end;
{
Table 'log' in database 'syncovery_log.sqlite3' has the following structure:
CREATE TABLE log (
id INTEGER PRIMARY KEY AUTOINCREMENT,
syncovery_hook TEXT NOT NULL,
profile_name TEXT NOT NULL,
file_name TEXT NOT NULL,
file_size BIGINT,
local_file_path TEXT,
complete_url TEXT,
is_right_side BOOLEAN,
timestamp DATETIME DEFAULT (datetime('now', 'localtime') )
);
}