Applies to: Syncplify.me Server!
Version(s): 1.x - 2.x - 3.x - 4.x - 5.x
Warning:    this articles refers to an older version of our software


The scripting framework in Syncplify.me Server!, which is used by the event-handling subsystem, is significantly different from the one found in previous versions. Yet, we did our best to preserve backward compatibility for the scripts you may have written in the past.


Differences that won’t affect your scripts:

  • Cached execution environment: creates fewer “script runner” objects and reuses them, thus improving memory usage and maximizing performance
  • Cached compiled scripts: a script is recompiled (if necessary) only when a new client connects to the server, inside the single session-thread the script is compiled only once and then run as many times as needed, thus improving performance
  • Added new run-time properties: ScriptID, ScriptName, VirtualObjectName, EventHandler, HandlerPriority

 

Differences that may affect your scripts:

  • Modified: SendToClient now accepts only 1 parameter, which is the message (string) to be sent to the client
  • Modified: ObjectName – this is probably the most significant change, as not all virtual file systems (VFS) may be able to remap remote objects to local file names, thus the local file name may not always exist (think of a file stored in the cloud, it does not have a local path on your disk) – if you need to log or send an email with the file name being uploaded/download, please consider using VirtualObjectName instead

 

Let us spend a few more words on the  ObjectName issue.


If your VFS is, for example, of type “Disk” and its root folder is “C:\Data\”, then when VirtualObjectName is “/docs/resume.docx” ObjectName will be “C:\Data\docs\resume.docx”, exactly the same as any previous version of our software.


But if your VFS is, for example, of type “Azure” (to be expected in v4.1) and its root is “MyCorpAzureContainer/Data”, then when  VirtualObjectName is “/docs/resume.docx” the ObjectName will be empty/undefined, as there is no way for your local Operating System to find the local path to a file that’s in the cloud.


Therefore, from Syncplify.me Server! version 4.0 on, the  ObjectName property should be considered deprecated, and all access and operation on files should be performed via the virtual file system (VFS) using only the VirtualObjectName property.


So, to be clear, this is the script you would use in Syncplify.me Server! v1-v3:


begin
  FileCopy(ObjectName, ObjectName+'.bak');
end.

And this is the equivalent script to be used in Syncplify.me Server! v4+:


begin
  VFS.FileCopy(VirtualObjectName, VirtualObjectName+'.bak');
end.


The first script may still work in Syncplify.me Server! v4 if and only if the VFS type is “Disk” or “DiskAES256”, while the second script will always work, regardless of the VFS type. Therefore it is strongly recommended that you update your scripts accordingly.