File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change 12
12
13
13
import magic
14
14
15
+ from zimscraperlib import logger
16
+
15
17
# override some MIME-types found by libmagic to different ones
16
18
MIME_OVERRIDES = {
17
19
"image/svg" : "image/svg+xml" ,
@@ -44,5 +46,7 @@ def get_content_mimetype(content: bytes | str) -> str:
44
46
45
47
def delete_callback (fpath : str | pathlib .Path ):
46
48
"""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 1
1
#!/usr/bin/env python
2
2
# vim: ai ts=4 sts=4 et sw=4 nu
3
3
4
+ import pathlib
5
+
4
6
import magic
5
7
6
8
from zimscraperlib .filesystem import (
@@ -51,3 +53,5 @@ def test_delete_callback(tmp_path):
51
53
delete_callback (fpath )
52
54
53
55
assert not fpath .exists ()
56
+
57
+ delete_callback (pathlib .Path ("/foo.txt" ))
You can’t perform that action at this time.
0 commit comments