Module: Agent::Lock::Manager::Thaw

Defined in:
lib/agent/lock/manager/thaw.rb

Overview

Thawing what a lock froze, in the checkout that froze it.

A frozen path is relative to the root of the checkout the lock was taken in, which need not be the checkout of the command giving the lock up: a reap, a parent's release-all, a resume and switch-backend --discard-locks all reach locks taken in another worktree. Thawing only in the checkout at hand deleted such a lock and left its files uchg, with the list of them gone in the record, so that neither release nor break could find anything to thaw. The thaw goes to the root the record names instead.

Only on this host. Another machine's files cannot be reached from here, and its list must not be applied to this one: the same relative path here is a different file, which may be frozen under a lock of its own.

Defined Under Namespace

Classes: Checkout

Class Method Summary collapse

Class Method Details

.call(record) ⇒ Array<String>

Best effort, as Freeze.clear is. A worktree removed since has nothing left to thaw, rm -rf being unable to remove a frozen file, and so is no reason to keep its lock. One moved since is not found: the record names only where it was.

Parameters:

Returns:

  • (Array<String>) —

    the paths still frozen because their files are on another machine: all of them, or none



45
46
47
48
49
50
51
# File 'lib/agent/lock/manager/thaw.rb', line 45

def call(record)
  home = home_of(record)
  return record.frozen_paths unless home

  Freeze.clear(record.frozen_paths, tree: home)
  []
end

.home_of(record) ⇒ Checkout?

Being local to the checkout it names is what a record on this host is, wherever the command asking runs.

Parameters:

Returns:

  • (Checkout, nil) —

    where its files are; nil when they are on another machine, or the record names no checkout



59
60
61
62
63
64
# File 'lib/agent/lock/manager/thaw.rb', line 59

def home_of(record)
  return nil if record.tree.nil?

  home = Checkout.new(root: record.tree)
  home if record.local_to?(home)
end