This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
from typing import Final
|
||||
|
||||
@@ -9,9 +10,14 @@ class FileHandlerAPI(FileHandler):
|
||||
def __init__(self, folder: Path):
|
||||
self.folder: Final = folder
|
||||
|
||||
def create(self, filename: str, content: bytes, text: bool = False):
|
||||
self.folder.mkdir(exist_ok=True)
|
||||
with open(self.folder.joinpath(filename), "wb") as fp:
|
||||
fp.write(content)
|
||||
dump_api_message("file", {"filename": filename, "size": len(content)})
|
||||
def make_path(self, filename: str) -> Path:
|
||||
return self.folder.joinpath(filename)
|
||||
|
||||
def notify_created(self, path: Path):
|
||||
dump_api_message("file", {"filename": path.name, "size": os.stat(path).st_size})
|
||||
|
||||
def _create(self, path: Path, content: bytes, text: bool = False):
|
||||
self.folder.mkdir(exist_ok=True)
|
||||
with open(path, "wb") as fp:
|
||||
fp.write(content)
|
||||
return path
|
||||
|
Reference in New Issue
Block a user