jgm/pandocfilters

"Could not create directory" error when get_filename4code is used

hadjian opened this issue · 3 comments

imagedir = tempfile.mkdtemp(prefix=module)

pandoc version: 1.17.0.1
python version: 3.8.12 or 3.9.7

I use the pandoc-plantuml filter, which make use of the get_filename4code function to create a temp dir. In the code linked above tempfile.mkdtemp(prefix=module) is invoked to create an imagedir name to be created with a later call to os.mkdir(imagedir).

On my setup however, the call to tempfile not only creates the name but also creates the dir, which later returns an error, when the dir is tried to be created again. This results in the error message "Could not create directory".

ickc commented

Can you also provide the OS type?

meanwhile you can revert to previous release which IIRC is 1.4

I am using Linux, Ubuntu 18.04.06

Thanks for the hint. I just moved the os.mkdir() call to the else clause and I noticed that it is also not checked whether the directory already exists. I think when not using the temporary directory, which is cleaned up, the directory is supposed to be used as a cache somehow. Then its existence should be expected and checked?

Thanks for the prompt answer.

ickc commented

Thanks.

C.f. #87, #88 and ping @jerri.