mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-26 21:51:02 +03:00
Revert "modules: Throttle the "downloading modules …" log entries"
This reverts commit 66904097e0
.
This commit is contained in:
parent
eb5fd3127f
commit
28d844642a
2 changed files with 18 additions and 28 deletions
|
@ -18,7 +18,6 @@ import (
|
|||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
|
@ -47,6 +46,8 @@ import (
|
|||
|
||||
"github.com/gohugoio/hugo/common/hugio"
|
||||
|
||||
"errors"
|
||||
|
||||
"github.com/spf13/afero"
|
||||
)
|
||||
|
||||
|
@ -104,25 +105,10 @@ func NewClient(cfg ClientConfig) *Client {
|
|||
noVendor, _ = hglob.GetGlob(hglob.NormalizePath(cfg.ModuleConfig.NoVendor))
|
||||
}
|
||||
|
||||
var throttleSince time.Time
|
||||
throttle := func(f func()) {
|
||||
if throttleSince.IsZero() {
|
||||
throttleSince = time.Now()
|
||||
f()
|
||||
return
|
||||
}
|
||||
if time.Since(throttleSince) < 6*time.Second {
|
||||
return
|
||||
}
|
||||
throttleSince = time.Now()
|
||||
f()
|
||||
}
|
||||
|
||||
return &Client{
|
||||
fs: fs,
|
||||
ccfg: cfg,
|
||||
logger: logger,
|
||||
throttle: throttle,
|
||||
noVendor: noVendor,
|
||||
moduleConfig: mcfg,
|
||||
environ: env,
|
||||
|
@ -132,9 +118,8 @@ func NewClient(cfg ClientConfig) *Client {
|
|||
|
||||
// Client contains most of the API provided by this package.
|
||||
type Client struct {
|
||||
fs afero.Fs
|
||||
logger loggers.Logger
|
||||
throttle func(f func())
|
||||
fs afero.Fs
|
||||
logger loggers.Logger
|
||||
|
||||
noVendor glob.Glob
|
||||
|
||||
|
@ -214,7 +199,7 @@ func (c *Client) Vendor() error {
|
|||
if err := c.rmVendorDir(vendorDir); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := c.fs.MkdirAll(vendorDir, 0o755); err != nil {
|
||||
if err := c.fs.MkdirAll(vendorDir, 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -275,7 +260,7 @@ func (c *Client) Vendor() error {
|
|||
} else {
|
||||
targetDir := filepath.Dir(targetFilename)
|
||||
|
||||
if err := c.fs.MkdirAll(targetDir, 0o755); err != nil {
|
||||
if err := c.fs.MkdirAll(targetDir, 0755); err != nil {
|
||||
return fmt.Errorf("failed to make target dir: %w", err)
|
||||
}
|
||||
|
||||
|
@ -318,7 +303,7 @@ func (c *Client) Vendor() error {
|
|||
}
|
||||
|
||||
if modulesContent.Len() > 0 {
|
||||
if err := afero.WriteFile(c.fs, filepath.Join(vendorDir, vendorModulesFilename), modulesContent.Bytes(), 0o666); err != nil {
|
||||
if err := afero.WriteFile(c.fs, filepath.Join(vendorDir, vendorModulesFilename), modulesContent.Bytes(), 0666); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@ -573,7 +558,7 @@ func (c *Client) rewriteGoMod(name string, isGoMod map[string]bool) error {
|
|||
return err
|
||||
}
|
||||
if data != nil {
|
||||
if err := afero.WriteFile(c.fs, filepath.Join(c.ccfg.WorkingDir, name), data, 0o666); err != nil {
|
||||
if err := afero.WriteFile(c.fs, filepath.Join(c.ccfg.WorkingDir, name), data, 0666); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@ -651,8 +636,7 @@ func (c *Client) rmVendorDir(vendorDir string) error {
|
|||
func (c *Client) runGo(
|
||||
ctx context.Context,
|
||||
stdout io.Writer,
|
||||
args ...string,
|
||||
) error {
|
||||
args ...string) error {
|
||||
if c.goBinaryStatus != 0 {
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue