diff options
author | Alexander <alex@spline.inf.fu-berlin.de> | 2015-08-28 02:43:22 +0200 |
---|---|---|
committer | Alexander <alex@spline.inf.fu-berlin.de> | 2015-08-28 02:43:22 +0200 |
commit | b5e718d6f4d37ca31c12eef603c6199c4b89a046 (patch) | |
tree | 3f8a96985aae9a998a9a65e9cc8bda3f12ae0fc0 /src/git_tftpd/backend.py | |
download | git-tftpd-b5e718d6f4d37ca31c12eef603c6199c4b89a046.tar.gz git-tftpd-b5e718d6f4d37ca31c12eef603c6199c4b89a046.tar.bz2 git-tftpd-b5e718d6f4d37ca31c12eef603c6199c4b89a046.zip |
Initial commit
Diffstat (limited to 'src/git_tftpd/backend.py')
-rw-r--r-- | src/git_tftpd/backend.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/git_tftpd/backend.py b/src/git_tftpd/backend.py new file mode 100644 index 0000000..6fae5bd --- /dev/null +++ b/src/git_tftpd/backend.py @@ -0,0 +1,30 @@ +from .writer import GitWriter + +from tftp.backend import IBackend +from tftp.errors import Unsupported, AccessViolation +from tftp.util import deferred + +from twisted.python.context import get +from twisted.python.filepath import FilePath, InsecurePath + +from zope import interface + + +class GitBackend(object): + interface.implements(IBackend) + + def __init__(self, base_path): + self.base_path = base_path + self.base = FilePath(base_path) + + @deferred + def get_reader(self, file_name): + raise Unsupported("Reading not supported") + + @deferred + def get_writer(self, file_name): + try: + target_path = self.base.descendant(file_name.split("/")) + except InsecurePath, e: + raise AccessViolation("Insecure path: %s" % e) + return GitWriter(target_path, self.base_path, get('remote')) |