mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-13 10:52:15 +01:00
Updating dependencies and fixing lint issues
This commit is contained in:
@@ -97,7 +97,8 @@ func (p chromePrinter) Print(destination string) error {
|
||||
defer devtConn.Close() // nolint: errcheck
|
||||
// create a new CDP Client that uses conn.
|
||||
devtClient := cdp.NewClient(devtConn)
|
||||
newContextTarget, err := devtClient.Target.CreateBrowserContext(ctx)
|
||||
createBrowserContextArgs := target.NewCreateBrowserContextArgs()
|
||||
newContextTarget, err := devtClient.Target.CreateBrowserContext(ctx, createBrowserContextArgs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -162,7 +163,7 @@ func (p chromePrinter) Print(destination string) error {
|
||||
// apply a wait delay (if any).
|
||||
if p.opts.WaitDelay > 0.0 {
|
||||
// wait for a given amount of time (useful for javascript delay).
|
||||
p.logger.DebugfOp(op, "applying a wait delay of '%.2fs'...", p.opts.WaitDelay)
|
||||
p.logger.DebugOpf(op, "applying a wait delay of '%.2fs'...", p.opts.WaitDelay)
|
||||
time.Sleep(xtime.Duration(p.opts.WaitDelay))
|
||||
} else {
|
||||
p.logger.DebugOp(op, "no wait delay to apply, moving on...")
|
||||
@@ -183,8 +184,8 @@ func (p chromePrinter) Print(destination string) error {
|
||||
if p.opts.PageRanges != "" {
|
||||
printToPdfArgs.SetPageRanges(p.opts.PageRanges)
|
||||
}
|
||||
// print the page to PDF.
|
||||
print, err := targetClient.Page.PrintToPDF(
|
||||
// printToPDF the page to PDF.
|
||||
printToPDF, err := targetClient.Page.PrintToPDF(
|
||||
ctx,
|
||||
printToPdfArgs,
|
||||
)
|
||||
@@ -209,7 +210,7 @@ func (p chromePrinter) Print(destination string) error {
|
||||
}
|
||||
return err
|
||||
}
|
||||
if err := ioutil.WriteFile(destination, print.Data, 0644); err != nil {
|
||||
if err := ioutil.WriteFile(destination, printToPDF.Data, 0600); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
@@ -282,7 +283,7 @@ func (p chromePrinter) setCustomHTTPHeaders(ctx context.Context, client *cdp.Cli
|
||||
// useless but for the logs.
|
||||
for key, value := range p.opts.CustomHTTPHeaders {
|
||||
customHTTPHeaders[key] = value
|
||||
p.logger.DebugfOp(op, "set '%s' to custom HTTP header '%s'", value, key)
|
||||
p.logger.DebugOpf(op, "set '%s' to custom HTTP header '%s'", value, key)
|
||||
}
|
||||
b, err := json.Marshal(customHTTPHeaders)
|
||||
if err != nil {
|
||||
@@ -357,7 +358,7 @@ func (p chromePrinter) listenEvents(ctx context.Context, client *cdp.Client) err
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p.logger.DebugfOp(op, "event '%s' received", ev.Name)
|
||||
p.logger.DebugOpf(op, "event '%s' received", ev.Name)
|
||||
if ev.Name == networkIdleEventName {
|
||||
break
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ func NewMarkdownPrinter(logger xlog.Logger, fpath string, opts ChromePrinterOpti
|
||||
baseFilename := xrand.Get()
|
||||
dst := fmt.Sprintf("%s/%s.html", dirPath, baseFilename)
|
||||
logger.DebugOp(op, "writing the HTML from previous conversion(s) into new file...")
|
||||
if err := ioutil.WriteFile(dst, buffer.Bytes(), 0644); err != nil {
|
||||
if err := ioutil.WriteFile(dst, buffer.Bytes(), 0600); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return fmt.Sprintf("file://%s", dst), nil
|
||||
|
||||
@@ -57,7 +57,7 @@ func (p mergePrinter) Print(destination string) error {
|
||||
}
|
||||
// see https://github.com/thecodingmachine/gotenberg/issues/139.
|
||||
sort.Strings(p.fpaths)
|
||||
p.logger.DebugfOp(op, "merging '%v'...", p.fpaths)
|
||||
p.logger.DebugOpf(op, "merging '%v'...", p.fpaths)
|
||||
resolver := func() error {
|
||||
var args []string
|
||||
args = append(args, p.fpaths...)
|
||||
|
||||
@@ -64,11 +64,11 @@ func (p officePrinter) Print(destination string) error {
|
||||
for i, fpath := range p.fpaths {
|
||||
baseFilename := xrand.Get()
|
||||
tmpDest := fmt.Sprintf("%s/%d%s.pdf", dirPath, i, baseFilename)
|
||||
p.logger.DebugfOp(op, "converting '%s' to PDF...", fpath)
|
||||
p.logger.DebugOpf(op, "converting '%s' to PDF...", fpath)
|
||||
if err := p.unoconv(ctx, fpath, tmpDest); err != nil {
|
||||
return err
|
||||
}
|
||||
p.logger.DebugfOp(op, "'%s.pdf' created", baseFilename)
|
||||
p.logger.DebugOpf(op, "'%s.pdf' created", baseFilename)
|
||||
fpaths[i] = tmpDest
|
||||
}
|
||||
if len(fpaths) == 1 {
|
||||
|
||||
@@ -12,5 +12,5 @@ type Printer interface {
|
||||
|
||||
func logOptions(logger xlog.Logger, opts interface{}) {
|
||||
const op string = "printer.logOptions"
|
||||
logger.DebugfOp(op, "options: %+v", opts)
|
||||
logger.DebugOpf(op, "options: %+v", opts)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user