Changeset 288
- Timestamp:
- 01/26/10 16:35:03 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server/www/app/vendors/shells/upgrade.php
r224 r288 140 140 141 141 /** 142 * Upgrade filesystem layout 143 */ 144 public function filesystemLayout() 145 { 146 $requests = $this->Request->find('all', array( 147 'contain' => array( 148 'Job', 149 'Job.Result', 150 'Job.Application', 151 'Job.Platform', 152 ), 153 'conditions' => array('Request.root' => ''), 154 )); 155 156 $this->out(print_r($requests)); 157 return; 158 159 foreach ($requests as $request) { 160 $this->Request->id = $request['Request']['id']; 161 162 // Create a root directory 163 $root = 'requests' . DS . $request['Request']['id']; 164 $root_path = APP . 'files' . DS . $root; 165 @mkdir($root_path); 166 167 // Move the request file 168 if ($request['Request']['filename']) { 169 $source = APP . 'files' . DS . 'requests' . DS . $request['Request']['path']; 170 $target = $root_path . DS . 'source' . DS . $request['Request']['filename']; 171 172 @mkdir(dirname($target)); 173 if (copy($source, $target)) { 174 unlink($source); 175 $this->out("Copied $source to $target"); 176 } else { 177 $this->out("Could not copy $source to $target"); 178 } 179 } 180 181 // Update the Request object 182 $this->Request->set(array( 183 'root' => $root, 184 'path' => $root . DS . 'source', 185 )); 186 $this->Request->save(); 187 188 // Move the result files 189 foreach ($request['Job'] as $job) { 190 if ($job['Result'] && $job['Result']['filename']) { 191 $path = Inflector::slug($job['Application']['name']) . '_'; 192 $path .= Inflector::slug($job['version']) . '_'; 193 $path .= Inflector::slug($job['Platform']['name']); 194 195 $source = APP . 'files' . DS . 'results' . DS . $job['Result']['path']; 196 $target = $root_path . DS . $path . DS . $job['Result']['filename']; 197 198 @mkdir(dirname($target)); 199 if (copy($source, $target)) { 200 unlink($source); 201 $this->out("Copied $source to $target"); 202 } else { 203 $this->out("Could not copy $source to $target"); 204 } 205 206 $this->Result->id = $job['Result']['id']; 207 $this->Result->saveField('path', $root . DS . $path); 208 } 209 } 210 } 211 } 212 213 /** 142 214 * Print shell help 143 215 */
Note: See TracChangeset
for help on using the changeset viewer.