Skip to content

Commit

Permalink
Fix #174
Browse files Browse the repository at this point in the history
  • Loading branch information
hhrutter committed May 27, 2020
1 parent ed59dc3 commit 58a1e27
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 12 deletions.
7 changes: 4 additions & 3 deletions README.md
Expand Up @@ -95,7 +95,7 @@ Get the latest binary [here](https://github.com/pdfcpu/pdfcpu/releases).

### Using GOPATH

Required go version for building: go1.13 and up
Required go version for building: go1.14 and up

```
go get github.com/pdfcpu/pdfcpu/cmd/...
Expand All @@ -110,15 +110,16 @@ pdfcpu version
git clone https://github.com/pdfcpu/pdfcpu
cd pdfcpu/cmd/pdfcpu
go install
pdfcpu ve
pdfcpu version
```

### Using Homebrew (macOS)
```
brew install pdfcpu
pdfcpu version
```

### Using Docker
### Run in a Docker container

```
docker build -t pdfcpu .
Expand Down
36 changes: 27 additions & 9 deletions pkg/api/api.go
Expand Up @@ -775,7 +775,11 @@ func SplitFile(inFile, outDir string, span int, conf *pdf.Configuration) error {
log.CLI.Printf("splitting %s to %s/...\n", inFile, outDir)

defer func() {
f.Close()
if err != nil {
f.Close()
return
}
err = f.Close()
}()

return Split(f, outDir, filepath.Base(inFile), span, conf)
Expand Down Expand Up @@ -1388,9 +1392,7 @@ func ImportImagesFile(imgFiles []string, outFile string, imp *pdf.Import, conf *
os.Remove(tmpFile)
}
for _, f := range rc {
if err := f.Close(); err != nil {
return
}
f.Close()
}
return
}
Expand All @@ -1405,6 +1407,11 @@ func ImportImagesFile(imgFiles []string, outFile string, imp *pdf.Import, conf *
return
}
}
for _, f := range rc {
if err := f.Close(); err != nil {
return
}
}
}()

return ImportImages(rs, f2, rr, imp, conf)
Expand Down Expand Up @@ -1651,9 +1658,19 @@ func MergeCreateFile(inFiles []string, outFile string, conf *pdf.Configuration)
return err
}
defer func() {
f.Close()
for _, f := range ff {
if err != nil {
f.Close()
for _, f := range ff {
f.Close()
}
}
if err = f.Close(); err != nil {
return
}
for _, f := range ff {
if err = f.Close(); err != nil {
return
}
}
}()

Expand Down Expand Up @@ -1703,7 +1720,6 @@ func MergeAppendFile(inFiles []string, outFile string, conf *pdf.Configuration)
if err != nil {
f2.Close()
if f1 != nil {
f1.Close()
os.Remove(tmpFile)
}
for _, f := range ff {
Expand All @@ -1715,10 +1731,12 @@ func MergeAppendFile(inFiles []string, outFile string, conf *pdf.Configuration)
return
}
if f1 != nil {
if err = f1.Close(); err != nil {
if err = os.Rename(tmpFile, outFile); err != nil {
return
}
if err = os.Rename(tmpFile, outFile); err != nil {
}
for _, f := range ff {
if err = f.Close(); err != nil {
return
}
}
Expand Down

0 comments on commit 58a1e27

Please sign in to comment.