X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=diff.go;h=15de2cde8a6963476915f84f26a69044160d6aa7cf27ce732082a37292257fd4;hb=512b4ec45c040338f9aea5c1e53783b817dfb85198b801eba892a452681f40b0;hp=dda4fd9ded52ee8109d30cbf1974527600de590be43819023d0df4ab8fbb91f4;hpb=db65ffeff7274def395c8ee747873d0e9d8250b75f543b6ac0d7bbd079cce66d;p=glocate.git diff --git a/diff.go b/diff.go index dda4fd9..15de2cd 100644 --- a/diff.go +++ b/diff.go @@ -1,3 +1,20 @@ +/* +glocate -- ZFS-diff-friendly locate-like utility +Copyright (C) 2022-2023 Sergey Matveev + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, version 3 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + package main import ( @@ -61,6 +78,7 @@ func updateWithDiff(dbPath, strip string) *os.File { } isDir = cols[1] == "/" name := deoctalize(strings.TrimPrefix(cols[2], strip)) + name = strings.TrimRight(name, "/") if name == "" { continue } @@ -175,7 +193,7 @@ func updateWithDiff(dbPath, strip string) *os.File { if err != nil { log.Fatalln(err) } - tmp0, err := os.CreateTemp("", "glocate-idx") + tmp0, err := os.CreateTemp(TmpDir, "glocate-idx") if err != nil { log.Fatalln(err) } @@ -222,6 +240,9 @@ func updateWithDiff(dbPath, strip string) *os.File { ent.size = mods[0].size mods = mods[1:] } + if ent.IsDir() { + ent.size = 0 + } entsDirSizer <- ent } for len(adds) > 0 {