occ-install-or-update (proc)
public {occ-install-or-update
    timeout:Time = 0s,
    installer:{proc-type {new-root-url:Url, old-root-url:Url }:bool}
}:(permission?:bool, network?:bool, allowed?:bool, updated?:bool)
Import from: CURL.GUI.STANDARD. Defined in package CURL.GUI.DIALOGS.

Allows a network applet to make a local copy of itself in order to support occasionally connected computing.

timeout: How long to wait for other callers of occ-install-or-update to finish before we give up. Defaults to no waiting.
installer: A proc which can create a local copy of the applet. You may use occ-root-installer directly, or the result of calling occ-module-installer, to create a proc which can be used to install archives produced by the deployment tool in the IDE.

Returns

Returns permission? (the value of the implicit call to request-local-data-permission), network? (true if running from the network), allowed? (true if updating was allowed), and updated? (true if any update was done). If any of these values is false, all following values will also be false.

Description

This procedure will attempt to create, or update, a local copy of an applet.

First, request-local-data-permission will be called, and if permission is refused, this procedure will return, with permission? false.

Second, if the applet is not running from the network, then this procedure will return, with network? false.

Third, if any other applet on the machine is already inside occ-install-or-update, and timeout expires, then this procedure will return, with allowed? false.

Finally, the installer will be called, inside a with-file-caching-style block with the FileCachingStyle resynchronize, to do all the actual work, and if it returns false, then this procedure will return, with updated? false.

The new-root-url argument to the installer will be a new, writable, temporary directory, into which the local copy of the applet should be placed.

The old-root-url argument to the installer will be the read-only final location for the installation, and which, if it already exists, will contain the results of the last successful installation.

If installer throws no exceptions, and returns true, then a special curl-root.txt file will be created inside new-root-url, defining the curl root for the original applet, and then old-root-url will have its contents atomically replaced with those of new-root-url.

Note that the installer should return false if it determines that old-root-url is already up to date, to prevent any unnecessary work from being done.

Notes

See also process-get-effective-root.

Licensing

This procedure can only be used by an applet that has a Curl/Pro server license.