Skip to contents

Locks a resource on the improve server to prevent concurrent modifications by other users. This ensures data integrity during editing operations and prevents conflicts in collaborative pharmaceutical workflows.

Usage

lockResource(ident, from = pwd())

Arguments

ident

Resource identifier (entityId, resourceId, or path). See common_ident for supported identifier formats.

from

Base path for resolving relative paths. Defaults to current working directory from pwd.

Value

Logical value:

TRUE

Resource successfully locked by current user

FALSE

Lock failed - resource already locked by another user or server error

Details

Lock Behavior:

  • Only one user can hold a lock on a resource at a time

  • Lock prevents other users from editing until released with unlockResource

  • Lock is automatically released when session ends or times out

  • Requires editable session mode (see setEditable)

Lock Status: If the resource is already locked, a warning message indicates which user holds the lock. You must wait for them to unlock or contact an administrator for lock override.

Best Practice: Always unlock resources when finished editing to avoid blocking collaborators. Use try() or on.exit() to ensure unlocking even if errors occur.

References

ics1139

See also

unlockResource to release lock, setEditable to enable write operations, updateResource for refreshing resource state

Examples

if (FALSE) { # \dontrun{
# Connect and enable editing
improveConnect()
setEditable(TRUE)

# Lock a resource before editing
if (lockResource("MyAnalysis/data.csv")) {
  # Perform editing operations
  # ...

  # Always unlock when done
  unlockResource("MyAnalysis/data.csv")
} else {
  message("Resource is locked by another user")
}

# Safe pattern with automatic unlock
locked <- lockResource("MyAnalysis/results")
if (locked) {
  on.exit(unlockResource("MyAnalysis/results"))
  # Edit operations here
}
} # }