/** * @param array $files * @param int $orderID * @return HTMLText */ protected function initiateOfflineProcessing(array $files, $orderID) { // is there already an existing temp file for this combination? $existingFile = DownloadTempFile::get_by_files($files); if ($existingFile && $existingFile->exists()) { if ($existingFile->ProcessingState === DownloadTempFile::COMPLETE) { $this->addToLog($orderID, $files, $existingFile); return $this->sendTempFile($existingFile); } else { return $this->displayCrunchingPage($existingFile); } } // this will get logged when crunching is complete Session::set('DownloadableProcessingOrderID', $orderID); // Create an empty DownloadTempFile $parent = Folder::find_or_make(Config::inst()->get('Downloadable', 'zip_folder')); $dl = new DownloadTempFile(); $dl->setParentID($parent->ID); $dl->Title = sha1(uniqid()); $dl->Name = $dl->Title . '.' . (count($files) == 1 ? $files[0]->getExtension() : 'zip'); $dl->write(); foreach ($files as $file) { $dl->SourceFiles()->add($file); } $dl->updateFileKey(); $dl->write(); // Display the "crunching" page so the user isn't left wondering what's going on return $this->displayCrunchingPage($dl); }