Commit 10d9fed4 authored by Łukasz Nowak's avatar Łukasz Nowak

Follow shadir and shacache spec change.

parent b2134dc5
...@@ -557,9 +557,8 @@ class Handler(BaseHTTPServer.BaseHTTPRequestHandler): ...@@ -557,9 +557,8 @@ class Handler(BaseHTTPServer.BaseHTTPRequestHandler):
class NCHandler(Handler): class NCHandler(Handler):
def do_POST(self): def do_POST(self):
path = os.path.abspath(os.path.join(self.tree, *self.path.split('/'))) path = os.path.abspath(os.path.join(self.tree, *self.path.split('/')))
d = os.path.dirname(path) if not os.path.exists(path):
if not os.path.exists(d): os.makedirs(path)
os.makedirs(d)
data = self.rfile.read(int(self.headers.getheader('content-length'))) data = self.rfile.read(int(self.headers.getheader('content-length')))
sha512 = hashlib.sha512(data).hexdigest() sha512 = hashlib.sha512(data).hexdigest()
try: try:
...@@ -568,7 +567,7 @@ class NCHandler(Handler): ...@@ -568,7 +567,7 @@ class NCHandler(Handler):
pass pass
else: else:
data = json.dumps([d]) data = json.dumps([d])
open(path, 'wb').write(data) open(os.path.join(path, sha512), 'wb').write(data)
self.send_response(201) self.send_response(201)
self.send_header('Content-Length', str(len(sha512))) self.send_header('Content-Length', str(len(sha512)))
self.send_header('Content-Type', 'text/html') self.send_header('Content-Type', 'text/html')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment