Restructure variable initializations
This commit is contained in:
parent
eaed4f11ef
commit
e9a3ae5e58
14
cmd/files.go
14
cmd/files.go
|
@ -327,14 +327,8 @@ Poll:
|
||||||
func scanPaths(paths []string, sort string, index *fileIndex, formats types.Types) ([]string, error) {
|
func scanPaths(paths []string, sort string, index *fileIndex, formats types.Types) ([]string, error) {
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
|
|
||||||
var list []string
|
var filesMatched, filesSkipped int
|
||||||
|
var directoriesMatched, directoriesSkipped int
|
||||||
var filesMatched int
|
|
||||||
var filesSkipped int
|
|
||||||
var directoriesMatched int
|
|
||||||
var directoriesSkipped int
|
|
||||||
|
|
||||||
var wg sync.WaitGroup
|
|
||||||
|
|
||||||
fileChannel := make(chan string)
|
fileChannel := make(chan string)
|
||||||
errorChannel := make(chan error)
|
errorChannel := make(chan error)
|
||||||
|
@ -347,6 +341,8 @@ func scanPaths(paths []string, sort string, index *fileIndex, formats types.Type
|
||||||
directoriesSkipped: make(chan int),
|
directoriesSkipped: make(chan int),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var list []string
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
@ -402,6 +398,8 @@ func scanPaths(paths []string, sort string, index *fileIndex, formats types.Type
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
var wg sync.WaitGroup
|
||||||
|
|
||||||
for i := 0; i < len(paths); i++ {
|
for i := 0; i < len(paths); i++ {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
|
|
||||||
|
|
28
cmd/info.go
28
cmd/info.go
|
@ -20,8 +20,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func paginateIndex(page int, fileCount int, ending bool) string {
|
func paginateIndex(page int, fileCount int, ending bool) string {
|
||||||
var html strings.Builder
|
|
||||||
|
|
||||||
var firstPage int = 1
|
var firstPage int = 1
|
||||||
var lastPage int
|
var lastPage int
|
||||||
|
|
||||||
|
@ -51,6 +49,8 @@ func paginateIndex(page int, fileCount int, ending bool) string {
|
||||||
nextPage = fileCount / PageLength
|
nextPage = fileCount / PageLength
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var html strings.Builder
|
||||||
|
|
||||||
if ending {
|
if ending {
|
||||||
html.WriteString("<tr><td style=\"border-bottom:none;\">")
|
html.WriteString("<tr><td style=\"border-bottom:none;\">")
|
||||||
} else {
|
} else {
|
||||||
|
@ -82,10 +82,10 @@ func paginateIndex(page int, fileCount int, ending bool) string {
|
||||||
|
|
||||||
func serveIndexHtml(args []string, index *fileIndex, shouldPaginate bool) httprouter.Handle {
|
func serveIndexHtml(args []string, index *fileIndex, shouldPaginate bool) httprouter.Handle {
|
||||||
return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
||||||
w.Header().Set("Content-Type", "text/html")
|
|
||||||
|
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
|
|
||||||
|
w.Header().Set("Content-Type", "text/html")
|
||||||
|
|
||||||
indexDump := index.List()
|
indexDump := index.List()
|
||||||
|
|
||||||
fileCount := len(indexDump)
|
fileCount := len(indexDump)
|
||||||
|
@ -159,10 +159,10 @@ func serveIndexHtml(args []string, index *fileIndex, shouldPaginate bool) httpro
|
||||||
|
|
||||||
func serveIndexJson(args []string, index *fileIndex, errorChannel chan<- error) httprouter.Handle {
|
func serveIndexJson(args []string, index *fileIndex, errorChannel chan<- error) httprouter.Handle {
|
||||||
return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
||||||
w.Header().Set("Content-Type", "application/json")
|
|
||||||
|
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
|
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
|
||||||
indexedFiles := index.List()
|
indexedFiles := index.List()
|
||||||
|
|
||||||
fileCount := len(indexedFiles)
|
fileCount := len(indexedFiles)
|
||||||
|
@ -217,10 +217,10 @@ func serveIndexJson(args []string, index *fileIndex, errorChannel chan<- error)
|
||||||
|
|
||||||
func serveAvailableExtensions(errorChannel chan<- error) httprouter.Handle {
|
func serveAvailableExtensions(errorChannel chan<- error) httprouter.Handle {
|
||||||
return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
||||||
w.Header().Set("Content-Type", "text/plain")
|
|
||||||
|
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
|
|
||||||
|
w.Header().Set("Content-Type", "text/plain")
|
||||||
|
|
||||||
written, err := w.Write([]byte(types.SupportedFormats.GetExtensions()))
|
written, err := w.Write([]byte(types.SupportedFormats.GetExtensions()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errorChannel <- err
|
errorChannel <- err
|
||||||
|
@ -239,10 +239,10 @@ func serveAvailableExtensions(errorChannel chan<- error) httprouter.Handle {
|
||||||
|
|
||||||
func serveEnabledExtensions(formats types.Types, errorChannel chan<- error) httprouter.Handle {
|
func serveEnabledExtensions(formats types.Types, errorChannel chan<- error) httprouter.Handle {
|
||||||
return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
||||||
w.Header().Set("Content-Type", "text/plain")
|
|
||||||
|
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
|
|
||||||
|
w.Header().Set("Content-Type", "text/plain")
|
||||||
|
|
||||||
written, err := w.Write([]byte(formats.GetExtensions()))
|
written, err := w.Write([]byte(formats.GetExtensions()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errorChannel <- err
|
errorChannel <- err
|
||||||
|
@ -261,10 +261,10 @@ func serveEnabledExtensions(formats types.Types, errorChannel chan<- error) http
|
||||||
|
|
||||||
func serveAvailableMediaTypes(errorChannel chan<- error) httprouter.Handle {
|
func serveAvailableMediaTypes(errorChannel chan<- error) httprouter.Handle {
|
||||||
return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
||||||
w.Header().Set("Content-Type", "text/plain")
|
|
||||||
|
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
|
|
||||||
|
w.Header().Set("Content-Type", "text/plain")
|
||||||
|
|
||||||
written, err := w.Write([]byte(types.SupportedFormats.GetMediaTypes()))
|
written, err := w.Write([]byte(types.SupportedFormats.GetMediaTypes()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errorChannel <- err
|
errorChannel <- err
|
||||||
|
@ -283,10 +283,10 @@ func serveAvailableMediaTypes(errorChannel chan<- error) httprouter.Handle {
|
||||||
|
|
||||||
func serveEnabledMediaTypes(formats types.Types, errorChannel chan<- error) httprouter.Handle {
|
func serveEnabledMediaTypes(formats types.Types, errorChannel chan<- error) httprouter.Handle {
|
||||||
return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
||||||
w.Header().Set("Content-Type", "text/plain")
|
|
||||||
|
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
|
|
||||||
|
w.Header().Set("Content-Type", "text/plain")
|
||||||
|
|
||||||
written, err := w.Write([]byte(formats.GetMediaTypes()))
|
written, err := w.Write([]byte(formats.GetMediaTypes()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errorChannel <- err
|
errorChannel <- err
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ReleaseVersion string = "3.3.0"
|
ReleaseVersion string = "3.3.1"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
Loading…
Reference in New Issue