I'd like to implement saving files to disk, but to do so I first need to decide on the directory structure. Django's FileField model field wants to upload files relative to MEDIA_ROOT[1]. Since I'm currently using the main site's CSS and images directly, MEDIA_ROOT hasn't been used yet. To simplify the problem I think it's best to simply ignore the fact that there may be an SCM backend. We should just focus on the relative directory structure. The easy way to go would be dumping everything into MEDIA_ROOT/repository/package_name/ (possible using MEDIA_ROOT/packages/...). It's simple and easy to navigate. The directory would hold the PKGBUILD, and source or install files and the tarball. The files would be accessible via MEDIA_URL/[packages/]repository/package_name/, with packages/ being optional. I'm not sure that using MEDIA_ROOT is a good idea since, if we eventually get some, images and CSS files, etc. would also go into it, so it seems a bit odd. Also if we do choose to go with an SCM like subversion then it would most likely have to be separated from the MEDIA_ROOT. I'm not sure if overloading this behaviour of the FileField is possible, so we may simply need to use a CharField and do anything, that FileField does for us, manually. For those familiar with the current AUR code, how does AUR do it? Does it even store the source file separately? And how does the main site handle it? [1] http://www.djangoproject.com/documentation/model-api/#filefield
Since there were no replies I just went ahead and implemented one I thought was the most logical. Sources, along with the PKGBUILD/tarball are now saved to the filesystem and properly recorded. I still need to implement downloading the tarball properly. At the moment it just gets the file off the file system, but in order to count the number of downloads I'd need to make it go through a view. Here's a sample directory listing: media/packages |-- catdvi | |-- catdvi.tar.gz | `-- sources | `-- PKGBUILD |-- dbhub | |-- dbhub.tar.gz | `-- sources | `-- PKGBUILD |-- grc | |-- grc.tar.gz | `-- sources | |-- PKGBUILD | `-- install.sh.patch |-- iimms2-git | |-- iimms2-git.tar.gz | `-- sources | |-- PKGBUILD | `-- config.mk `-- slim-theme-the_bait |-- slim-theme-the_bait.tar.gz `-- sources |-- PKGBUILD |-- slim-theme-the_bait-1.tar.gz `-- the_bait.install And of course a screenshot: http://omploader.org/vYWJi
participants (1)
-
Sebastian Nowicki