Address review feedback

This commit is contained in:
Gunnsteinn Hall 2019-01-28 11:21:17 +00:00
parent 24dbf33807
commit b5714c231b
3 changed files with 11 additions and 11 deletions

View File

@ -56,7 +56,6 @@ func probeAllObjectsSinglePdf(inputPath string) error {
if err != nil { if err != nil {
return err return err
} }
defer f.Close() defer f.Close()
pdfReader, err := model.NewPdfReader(f) pdfReader, err := model.NewPdfReader(f)

View File

@ -20,7 +20,7 @@ import (
// Set environment variables: // Set environment variables:
// UNIDOC_E2E_FORCE_TESTS to "1" to force the tests to execute. // UNIDOC_E2E_FORCE_TESTS to "1" to force the tests to execute.
// UNIDOC_PASSTHROUGH_TESTDATA to the path of the corpus folder. // UNIDOC_PASSTHROUGH_TESTDATA to the path of the corpus folder.
// UNIDOC_GS_BIN_PATH to the path of the ghosccript binary (gs). // UNIDOC_GS_BIN_PATH to the path of the ghostscript binary (gs).
var ( var (
forceTest = os.Getenv("UNIDOC_E2E_FORCE_TESTS") == "1" forceTest = os.Getenv("UNIDOC_E2E_FORCE_TESTS") == "1"
passthroughCorpusFolder = os.Getenv("UNIDOC_PASSTHROUGH_TESTDATA") passthroughCorpusFolder = os.Getenv("UNIDOC_PASSTHROUGH_TESTDATA")
@ -55,7 +55,7 @@ func TestPassthrough(t *testing.T) {
params := passthroughParams{ params := passthroughParams{
inputPath: fpath, inputPath: fpath,
outPath: filepath.Join(tempdir, "1.pdf"), outPath: filepath.Join(tempdir, "1.pdf"),
gsValidation: false, gsValidation: len(ghostscriptBinPath) > 0,
} }
err := passthroughSinglePdf(params) err := passthroughSinglePdf(params)
if err != nil { if err != nil {

View File

@ -18,7 +18,7 @@ import (
// To enable ghostscript validation, the path to the binary needs to be specified. // To enable ghostscript validation, the path to the binary needs to be specified.
// Set environment variable: // Set environment variable:
// UNIDOC_GS_BIN_PATH to the path of the ghosccript binary (gs). // UNIDOC_GS_BIN_PATH to the path of the ghostscript binary (gs).
var ( var (
ghostscriptBinPath = os.Getenv("UNIDOC_GS_BIN_PATH") ghostscriptBinPath = os.Getenv("UNIDOC_GS_BIN_PATH")
) )
@ -32,16 +32,17 @@ func validatePdf(path string, password string) (int, error) {
} }
common.Log.Debug("Validating: %s", path) common.Log.Debug("Validating: %s", path)
var cmd *exec.Cmd params := []string{"-dBATCH", "-dNODISPLAY", "-dNOPAUSE"}
if len(password) > 0 { if len(password) > 0 {
option := fmt.Sprintf("-sPDFPassword=%s", password) params = append(params, fmt.Sprintf("-sPDFPassword=%s", password))
cmd = exec.Command(ghostscriptBinPath, "-dBATCH", "-dNODISPLAY", "-dNOPAUSE", option, path)
} else {
cmd = exec.Command(ghostscriptBinPath, "-dBATCH", "-dNODISPLAY", "-dNOPAUSE", path)
} }
params = append(params, path)
var out bytes.Buffer var (
var errOut bytes.Buffer out bytes.Buffer
errOut bytes.Buffer
)
cmd := exec.Command(ghostscriptBinPath, params...)
cmd.Stdout = &out cmd.Stdout = &out
cmd.Stderr = &errOut cmd.Stderr = &errOut