handle files with "bad" names
This commit is contained in:
parent
15eeeccb4b
commit
583113c846
1 changed files with 6 additions and 1 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
import datetime
|
||||
import sys
|
||||
import re
|
||||
import json
|
||||
from base64 import b64encode
|
||||
from pathlib import Path
|
||||
|
@ -99,7 +100,11 @@ class ArchiveBackend:
|
|||
return False
|
||||
|
||||
def reserve(self, filename: Path) -> str:
|
||||
bucketbase = filename.name.rsplit(".", maxsplit=1)[0].replace(".", "_")
|
||||
bucketbase = re.sub(
|
||||
r"""[^a-zA-Z0-9_.-]""", # based on what the archive.org documentation says
|
||||
"_",
|
||||
filename.name.rsplit(".", maxsplit=1)[0]
|
||||
)
|
||||
if not bucketbase.startswith(f"{self.bucketprefix}-"):
|
||||
bucketbase = f"{self.bucketprefix}-" + bucketbase
|
||||
bucketname = bucketbase
|
||||
|
|
Loading…
Reference in a new issue