// ALR - Any Linux Repository // Copyright (C) 2025 The ALR Authors // // 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, either version 3 of the License, or // (at your option) any later version. // // 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 dl import ( "hash" "io" "os" "path/filepath" ) func HashDir(dirPath string, h hash.Hash) error { err := filepath.Walk(dirPath, func(path string, info os.FileInfo, err error) error { if err != nil { return err } // Skip .git directory if info.IsDir() && info.Name() == ".git" { return filepath.SkipDir } // Skip directories (only process files) if !info.Mode().IsRegular() { return nil } // Open file f, err := os.Open(path) if err != nil { return err } defer f.Close() // Write file content to hasher if _, err := io.Copy(h, f); err != nil { return err } return nil }) if err != nil { return err } return nil }