Skip to content

Commit

Permalink
portindex: Reuse entry from same portdir only
Browse files Browse the repository at this point in the history
If a port is moved from one directory to another, for example when the
category is changed, the port must be reindexed. Otherwise, PortIndex
still references the old portdir and any action on the port would fail
as the Portfile cannot be found.
  • Loading branch information
raimue committed May 17, 2018
1 parent bb9db18 commit aa2b75c
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions src/port/portindex.tcl
Expand Up @@ -120,24 +120,28 @@ proc pindex {portdir} {
set mtime [file mtime $portfile]
if {$oldmtime >= $mtime} {
lassign [_read_index $qname] name len line
_write_index $name $len $line
incr stats(skipped)
array set portinfo $line

if {[info exists ui_options(ports_debug)]} {
puts "Reusing existing entry for $portdir"
}
# reuse entry if it was made from the same portdir
if {[info exists portinfo(portdir)] && $portinfo(portdir) eq $portdir} {
_write_index $name $len $line
incr stats(skipped)

if {[info exists ui_options(ports_debug)]} {
puts "Reusing existing entry for $portdir"
}

# also reuse the entries for its subports
if {![info exists portinfo(subports)]} {
return
}
foreach sub $portinfo(subports) {
_write_index {*}[_read_index [string tolower $sub]]
incr stats(skipped)
}

# also reuse the entries for its subports
array set portinfo $line
if {![info exists portinfo(subports)]} {
return
}
foreach sub $portinfo(subports) {
_write_index {*}[_read_index [string tolower $sub]]
incr stats(skipped)
}

return
}
} catch {{*} eCode eMessage} {
ui_warn "Failed to open old entry for ${portdir}, making a new one"
Expand Down

0 comments on commit aa2b75c

Please sign in to comment.