zim-tools icon indicating copy to clipboard operation
zim-tools copied to clipboard

zimwriterfs doesn't clean up its temporary files on Ctrl+C

Open asashnov opened this issue 5 years ago • 2 comments

Version: curent master (243e869d)

Steps to reproduce:

  1. Prepare some HTML input directory, or extract existing .zim file as an example of content which takes some time to compress. For example:
$ ~/oz/zim-tools/build/src/zimdump dump --dir=wikipedia_en_100_maxi \
   ZIM.files/wikipedia_en_100_maxi_2020-05.zim

(33 Mb, md5sum starts with 366d22bd, it will take about 20 sec to compress it back)

  1. Start .zim file creation:
~/oz/zim-tools/build/src/zimwriterfs/zimwriterfs \
  --welcome=A/index --favicon=-/favicon --language=eng --title=mytest \
  --description=ThisIsATest --creator=self --publisher=self --inflateHtml \
  --verbose ~/oz/wikipedia_en_100_maxi ~/oz/result.zim
  1. Interrupt the process with Ctrl+C after few seconds. More files will be left if press Ctrl+C after you see Waiting for workers line in terminal.

Actual result:

Temporary files are left behind in the .zim target directory:

-rw-r--r--  1 user user   1810432 окт 29 23:47 result.idx
drwxr-xr-x  2 user user      4096 окт 29 23:47 result.idx.tmp
-rw-r--r--  1 user user    155648 окт 29 23:47 result_title.idx
drwxr-xr-x  2 user user      4096 окт 29 23:47 result_title.idx.tmp
-rw-r--r--  1 user user  38128069 окт 29 23:47 result.zim.tmp

Expected result:

All temporary files listed above should be deleted after program exits by Ctrl+C

Additional information:

If wait until the process finished no extra files or directories are left, only the resulting .zim file.

asashnov avatar Oct 29 '20 16:10 asashnov

@mgautierfr I'm not even sure if we can/want a handled interruption. Do you? For me if you interrupt the process, this is normal to have a few side effects.

kelson42 avatar Oct 30 '20 14:10 kelson42

Many programs print 'Interrupting...' if Ctrl+C pressed once, trying to exit gracefully, and exit immediately by pressing Ctrl+C again.

asashnov avatar Oct 31 '20 16:10 asashnov