Don't record paths more than once.
This commit is contained in:
parent
ff06547286
commit
bf55ccc22a
1 changed files with 18 additions and 15 deletions
|
|
@ -115,7 +115,8 @@ add_db_entry() {
|
||||||
|
|
||||||
# Process the paths to add to the database.
|
# Process the paths to add to the database.
|
||||||
store_attributes() {
|
store_attributes() {
|
||||||
local ACL ADD_COUNT=0 DB_TMP ERR_COUNT=0 EXTRA NAME PATHCOMPONENT PATHNAME PATHRECORD XATTR
|
local ACL ADD_COUNT=0 DB_TMP ERR_COUNT=0 EXTRA NAME PATHCOMPONENT PATHNAME XATTR
|
||||||
|
local -A SEEN
|
||||||
|
|
||||||
# Informational message.
|
# Informational message.
|
||||||
log "Storing path attributes into database"
|
log "Storing path attributes into database"
|
||||||
|
|
@ -136,14 +137,15 @@ store_attributes() {
|
||||||
[[ "$PATHNAME" == "$DB_FILE" ]] || [[ "$PATHNAME" == "$DB_EXTRA" ]] && continue
|
[[ "$PATHNAME" == "$DB_FILE" ]] || [[ "$PATHNAME" == "$DB_EXTRA" ]] && continue
|
||||||
|
|
||||||
# Add all paths leading up to the file to the database.
|
# Add all paths leading up to the file to the database.
|
||||||
PATHRECORD=""
|
|
||||||
while read -r -d '/' PATHCOMPONENT; do
|
while read -r -d '/' PATHCOMPONENT; do
|
||||||
|
[[ ! -v SEEN['$PATHCOMPONENT'] ]] && {
|
||||||
if add_db_entry "$PATHCOMPONENT"; then
|
if add_db_entry "$PATHCOMPONENT"; then
|
||||||
|
SEEN+=('$PATHCOMPONENT')
|
||||||
(( ADD_COUNT++ ))
|
(( ADD_COUNT++ ))
|
||||||
else
|
else
|
||||||
(( ERR_COUNT++ ))
|
(( ERR_COUNT++ ))
|
||||||
fi
|
fi
|
||||||
PATHRECORD+="$PATHCOMPONENT/"
|
}
|
||||||
done <<<"$PATHNAME"
|
done <<<"$PATHNAME"
|
||||||
# Add the file itself to the database.
|
# Add the file itself to the database.
|
||||||
if add_db_entry "$PATHNAME"; then
|
if add_db_entry "$PATHNAME"; then
|
||||||
|
|
@ -162,14 +164,15 @@ store_attributes() {
|
||||||
[[ "$NAME" == "$DB_FILE" ]] || [[ "$NAME" == "$DB_EXTRA" ]] && continue
|
[[ "$NAME" == "$DB_FILE" ]] || [[ "$NAME" == "$DB_EXTRA" ]] && continue
|
||||||
|
|
||||||
# Add all paths leading up to the file to the database.
|
# Add all paths leading up to the file to the database.
|
||||||
PATHRECORD=""
|
|
||||||
while read -r -d '/' PATHCOMPONENT; do
|
while read -r -d '/' PATHCOMPONENT; do
|
||||||
|
[[ ! -v SEEN['$PATHCOMPONENT'] ]] && {
|
||||||
if add_db_entry "$PATHCOMPONENT"; then
|
if add_db_entry "$PATHCOMPONENT"; then
|
||||||
|
SEEN+=('$PATHCOMPONENT')
|
||||||
(( ADD_COUNT++ ))
|
(( ADD_COUNT++ ))
|
||||||
else
|
else
|
||||||
(( ERR_COUNT++ ))
|
(( ERR_COUNT++ ))
|
||||||
fi
|
fi
|
||||||
PATHRECORD+="$PATHCOMPONENT/"
|
}
|
||||||
done <<<"$NAME"
|
done <<<"$NAME"
|
||||||
# Add the file itself to the database.
|
# Add the file itself to the database.
|
||||||
if add_db_entry "$NAME"; then
|
if add_db_entry "$NAME"; then
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue