### Eclipse Workspace Patch 1.0 #P babel_server Index: classes/file/file.class.php =================================================================== RCS file: /cvsroot/technology/org.eclipse.babel/server/classes/file/file.class.php,v retrieving revision 1.12 diff -u -r1.12 file.class.php --- classes/file/file.class.php 8 Oct 2008 13:58:14 -0000 1.12 +++ classes/file/file.class.php 18 Nov 2008 22:26:04 -0000 @@ -47,7 +47,7 @@ version = " . $App->returnQuotedString($App->sqlSanitize($this->version, $dbh)) . ", name = " . $App->returnQuotedString($App->sqlSanitize($this->name, $dbh)) . ", plugin_id = " . $App->returnQuotedString($App->sqlSanitize($this->plugin_id, $dbh)) . ", - is_active = 1" . $where; + is_active = " . $this->isActive . $where; if(mysql_query($sql, $dbh)) { if($this->file_id == 0) { $this->file_id = mysql_insert_id($dbh); @@ -68,7 +68,7 @@ } function getFileID($_name, $_project_id, $_version) { - $rValue = 0; + $rValue = -1; if($this->name != "" && $this->project_id != "" && $_version != "") { global $App, $dbh; Index: html/process_map_files.php =================================================================== RCS file: /cvsroot/technology/org.eclipse.babel/server/html/process_map_files.php,v retrieving revision 1.12 diff -u -r1.12 process_map_files.php --- html/process_map_files.php 12 Nov 2008 18:21:38 -0000 1.12 +++ html/process_map_files.php 18 Nov 2008 22:26:04 -0000 @@ -33,6 +33,18 @@ chdir("/tmp/tmp-babel") || die("Cannot use working directory"); +$files = array(); +$sql = "SELECT * from files"; +$rs_files = mysql_query($sql, $dbh); +while($myrow_file = mysql_fetch_assoc($rs_files)) { + $File = new File(); + $File->project_id = $myrow_file['project_id']; + $File->version = $myrow_file['version']; + $File->name = $myrow_file['name']; + $File->plugin_id = $myrow_file['plugin_id']; + $File->file_id = $myrow_file['file_id']; + $files[$File->file_id] = $File; +} $sql = "SELECT * FROM map_files WHERE is_active = 1 ORDER BY RAND()"; @@ -40,6 +52,7 @@ while($myrow_maps = mysql_fetch_assoc($rs_maps)) { echo "Processing map file: " . $myrow_maps['filename'] . " in location: " . $myrow_maps['location'] . "\n"; + $tmpdir = "/tmp/tmp-babel/" . $myrow_maps['project_id']; if(is_dir($tmpdir)) { # zap the directory to make sure CVS versions don't overlap @@ -109,11 +122,20 @@ $file_name = trim(substr($out_line, 2)); echo $html_spacer . $html_spacer . $html_spacer . "Processing .properties file: " . $file_name . "\n"; - $File = new File(); - $File->project_id = $myrow_maps['project_id']; - $File->version = $myrow_maps['version']; - $File->name = $file_name; - $File->plugin_id = $plugin_id; + $file_id = File->getFileID($file_name, $myrow_maps['project_id'], $myrow_maps['version']); + + if ($files[$file_id] != null) { + $File = $files[$file_id]; + $File->isActive = 1; + unset($files[$file_id]); + } else { + $File = new File(); + $File->project_id = $myrow_maps['project_id']; + $File->version = $myrow_maps['version']; + $File->name = $file_name; + $File->plugin_id = $plugin_id; + $File->isActive = 1; + } if(!$File->save()) { echo $html_spacer . $html_spacer . $html_spacer . $html_spacer . "***ERROR saving file: " . $file_name . "\n"; } @@ -135,6 +157,15 @@ } } } +echo "Marking the remaining files as inactive\n"; + +foreach ($files as $file) { + $file->isActive = 0; + if(!$file->save()) { + echo $html_spacer . $html_spacer . $html_spacer . $html_spacer . "***ERROR saving file: " . $file->name . "\n"; + } +} + echo "Done."; if($headless) {