diff --git a/TODO.txt b/TODO.txt index a029d5a..384c80d 100644 --- a/TODO.txt +++ b/TODO.txt @@ -3,8 +3,6 @@ - Merge "written in" and "tags" -- Per-project directories, to prevent overwriting files (e.g. 'screenshot.jpg') - - RSS for recent changes - RSS for all projects diff --git a/rebuild.php b/rebuild.php index 0646488..db2fef5 100644 --- a/rebuild.php +++ b/rebuild.php @@ -155,6 +155,7 @@ class CProject { private $longdesc = ''; private $images = array(); private $downloads = array(); + private $downloads_hashes = array(); public $tags = array(); public $homeimage = null; @@ -203,6 +204,12 @@ class CProject { natcasesort($this->downloads); $this->downloads = array_reverse($this->downloads); + + for($i = 0, $e = count($this->downloads); $i !== $e; ++$i) { + $this->downloads_hashes[] = ( + sha1_file($this->dir.$this->downloads[$i]) + ); + } } public function genHomeImage() { @@ -231,7 +238,21 @@ class CProject { // Copy downloads to wwwroot foreach($this->downloads as $idx => $filename) { - copy($this->dir.$filename, BASEDIR.'wwwroot/srv/'.$filename); + $cmkdir = @mkdir( BASEDIR.'wwwroot/srv/'.$this->downloads_hashes[$idx] ); + + if (! $cmkdir) { + fputs( + STDOUT, + "WARNING: Couldn't create directory ".$this->downloads_hashes[$idx]. + " for file '${filename}'". + " in project '".$this->projname."'!\n" + ); + } + + copy( + $this->dir.$filename, + BASEDIR.'wwwroot/srv/'.$this->downloads_hashes[$idx].'/'.$filename + ); } // Generate index page @@ -269,11 +290,11 @@ class CProject { DOWNLOAD