Skip to content

clean properly figures directory when multiple format - #1566

Merged
yihui merged 3 commits into
rstudio:masterfrom
cderv:fix-1553-clean-directory
Apr 12, 2019
Merged

yihui merged 3 commits into
rstudio:masterfrom
cderv:fix-1553-clean-directory

Conversation

@cderv

@cderv cderv commented Apr 11, 2019 •

Copy link
Copy Markdown
Collaborator

This is a proposal to help fix the issue related in #1553, #1472, #1503

issues corrected:

  • unlink does not support path ending with / (more precisely Sys.glob is used and does not support that). knitr::opts_chunk$get('fig.path') returns a path with / so it was not correctly removing the figure directory
  • At first time rendering, files_dir_fig was empty (character(0)) so figure dir was deleted but not the files_dir as it should if it was the only format used. An empty files_dir was still existing
  • if a format was run twice, the fig dir was already existing but other format could be present. identical() test was TRUE but we did not want to delete the all files dir.

This fix

  • trim the ending / for unlink fig directory to work
  • delete the whole file_dir if there is only one format to clean

Hoping it helps fixing those bugs.


This change is Reviewable

cderv added 2 commits April 11, 2019 08:28
* unlink does not support / at the end of a file path to remove it
* assume you can delete whole files folder is figure dir is the only one existing. If not only remove figure dir with correct path without / at the end

@yihui yihui left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks for the great help!!

@yihui yihui added this to the v1.13 milestone Apr 12, 2019
@yihui
yihui merged commit 9923811 into rstudio:master Apr 12, 2019
@cderv
cderv deleted the fix-1553-clean-directory branch July 26, 2019 15:57
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Nov 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants