admin: Create a GitImporter based on git binaries
This commit is contained in:
parent
23c43ad667
commit
43be59b97d
5 changed files with 133 additions and 35 deletions
39
admin/sync/importer_git_common.go
Normal file
39
admin/sync/importer_git_common.go
Normal file
|
@ -0,0 +1,39 @@
|
|||
package sync
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"os"
|
||||
)
|
||||
|
||||
func countFileInDir(dirname string) (int, error) {
|
||||
files, err := os.ReadDir(dirname)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return len(files), nil
|
||||
}
|
||||
|
||||
func (i GitImporter) exists(filename string) bool {
|
||||
return i.li.exists(filename)
|
||||
}
|
||||
|
||||
func (i GitImporter) toURL(filename string) string {
|
||||
return i.li.toURL(filename)
|
||||
}
|
||||
|
||||
func (i GitImporter) importFile(URI string, next func(string, string) (interface{}, error)) (interface{}, error) {
|
||||
return i.li.importFile(URI, next)
|
||||
}
|
||||
|
||||
func (i GitImporter) getFile(filename string, writer *bufio.Writer) error {
|
||||
return i.li.getFile(filename, writer)
|
||||
}
|
||||
|
||||
func (i GitImporter) listDir(filename string) ([]string, error) {
|
||||
return i.li.listDir(filename)
|
||||
}
|
||||
|
||||
func (i GitImporter) stat(filename string) (os.FileInfo, error) {
|
||||
return i.li.stat(filename)
|
||||
}
|
Reference in a new issue