mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-11 18:02:14 +01:00
Removing user profile directory when an Office conversion is over
This commit is contained in:
@@ -113,7 +113,15 @@ func (p officePrinter) unoconv(ctx context.Context, fpath, destination string) e
|
||||
args = append(args, "--export", fmt.Sprintf("PageRange=%s", p.opts.PageRanges))
|
||||
}
|
||||
args = append(args, "--output", destination, fpath)
|
||||
if err := xexec.Run(ctx, p.logger, "unoconv", args...); err != nil {
|
||||
err = xexec.Run(ctx, p.logger, "unoconv", args...)
|
||||
// always remove user profile folders created by LibreOffice.
|
||||
// see https://github.com/thecodingmachine/gotenberg/issues/192.
|
||||
userProfileDirPath := fmt.Sprintf("/tmp/%d", port)
|
||||
if err := os.RemoveAll(userProfileDirPath); err != nil {
|
||||
// find a way to bubble up this error?
|
||||
p.logger.ErrorOpf(op, "failed to remove user profile directory '%s'", userProfileDirPath)
|
||||
}
|
||||
if err != nil {
|
||||
// find a way to check it in the handlers?
|
||||
if p.opts.PageRanges != "" && strings.Contains(err.Error(), "exit status 5") {
|
||||
return xerror.Invalid(
|
||||
|
||||
Reference in New Issue
Block a user