X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=index.go;h=ce054cf647fed10ad507db8bd8a3de5583fed802328691e72c0aff04c6216150;hb=bdd5ab2cfb82e4a4c5961484c9170982594682c0547a855b31781ae05fa47381;hp=c6fa5398b74fb4ace31a4f09587b8579e3b9642d55040d46e92a1f37fe5e99fb;hpb=d5b8c235a1f3088c6c1e7261df3d1b565d042db2ba2ad1bbd1018782b9178e1f;p=glocate.git diff --git a/index.go b/index.go index c6fa539..ce054cf 100644 --- a/index.go +++ b/index.go @@ -1,14 +1,30 @@ +/* +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 ( - "bufio" "fmt" "log" "os" ) func index() *os.File { - tmp0, err := os.CreateTemp("", "glocate-idx") + tmp0, err := os.CreateTemp(TmpDir, "glocate-idx") if err != nil { log.Fatalln(err) } @@ -25,10 +41,9 @@ func index() *os.File { close(dirSizerJob) }() - bw := bufio.NewWriterSize(tmp0, 1<<17) writerJob := make(chan struct{}) go func() { - writer(bw, entsWriter) + writer(tmp0, entsWriter) close(writerJob) }() @@ -45,9 +60,6 @@ func index() *os.File { <-dirSizerJob close(entsWriter) <-writerJob - if err = bw.Flush(); err != nil { - log.Fatalln(err) - } tmp1 := applyDirSizes(tmp0, dirSizes) tmp0.Close()