File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212
1313import magic
1414
15+ from zimscraperlib import logger
16+
1517# override some MIME-types found by libmagic to different ones
1618MIME_OVERRIDES = {
1719 "image/svg" : "image/svg+xml" ,
@@ -44,5 +46,7 @@ def get_content_mimetype(content: bytes | str) -> str:
4446
4547def delete_callback (fpath : str | pathlib .Path ):
4648 """helper deleting passed filepath"""
47-
48- os .unlink (fpath )
49+ if not pathlib .Path (fpath ).exists ():
50+ logger .warning (f"delete callback: file { fpath } is already gone" )
51+ else :
52+ os .unlink (fpath )
Original file line number Diff line number Diff line change 11#!/usr/bin/env python
22# vim: ai ts=4 sts=4 et sw=4 nu
33
4+ import pathlib
5+
46import magic
57
68from zimscraperlib .filesystem import (
@@ -51,3 +53,5 @@ def test_delete_callback(tmp_path):
5153 delete_callback (fpath )
5254
5355 assert not fpath .exists ()
56+
57+ delete_callback (pathlib .Path ("/foo.txt" ))
You can’t perform that action at this time.
0 commit comments