From e37b040bc3a392f2705fbabf4123b61ad6ac05ee Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Mon, 18 Aug 2014 17:22:31 +0100 Subject: Small amounts of cleanup and bonus round comments. --- synapse/http/server.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/synapse/http/server.py b/synapse/http/server.py index 9b6ae993ab..42fb9f5e96 100644 --- a/synapse/http/server.py +++ b/synapse/http/server.py @@ -188,11 +188,13 @@ class ContentRepoResource(resource.Resource): Uploads are POSTed to wherever this Resource is linked to. This resource returns a "content token" which can be used to GET this content again. The - token is typically a path, but it may not be. + token is typically a path, but it may not be. Tokens can expire, be one-time + uses, etc. - In this case, the token contains 3 sections: + In this case, the token is a path to the file and contains 3 interesting + sections: - User ID base64d (for namespacing content to each user) - - random string + - random 24 char string - Content type base64d (so we can return it when clients GET it) """ @@ -205,7 +207,7 @@ class ContentRepoResource(resource.Resource): if not os.path.isdir(self.directory): os.mkdir(self.directory) - logger.info("FileUploadResource : Created %s directory.", + logger.info("ContentRepoResource : Created %s directory.", self.directory) @defer.inlineCallbacks @@ -271,6 +273,8 @@ class ContentRepoResource(resource.Resource): f = open(file_path, 'rb') request.setHeader('Content-Type', content_type) d = FileSender().beginFileTransfer(f, request) + + # after the file has been sent, clean up and finish the request def cbFinished(ignored): f.close() request.finish() -- cgit 1.4.1