Django migration: #47 (closed)
This MR adds package upload under the route /upload.
The route only accepts PUT method for uploading files.
Although the upload logic stay the same (re-upload files while upload is marked as incomplete: no .changes), a lot of the class/object representation in the code has changed. Here is a brief summary of how it works.
At the top, we have a Spool object that represents the actual location of the uploaded files and, later, where the files will be processed. There are two queues: incoming where the upload happens and processing for a later use.
The Spool object allow new files to be uploaded with upload(). This method checks if the file is already owned by a previous upload, checks some allowed extensions and return a file handler for the views to fill up with uploaded data.
Ownership of a file to a previous upload can be determined by a Changes object. That object is created from a .changes file that will be parsed and inherit properties of a GPGSignedFile (allowing later validation of the GPG signature). The Changes object holds a ControlFiles object representing a list of the files referenced in the .changes.
The list of files of a ControlFiles object are instances of CheckSumedFile. This new object allow checking of file integrity using the given hashes.
Those new types of objects (Changes, ControlFiles, CheckSumedFile and GPGSignedFile) allow a simple validation of a changes and its files:
changes = Changes('my.changes')
changes.validate() # validate mandatory fields for a .changes
changes.authenticate() # authenticate the file by its GPG key
changes.files.validate() # validate checksums of the files references by the .changes