public function sync()
 {
     if ($this->Files && count($this->Files)) {
         foreach ($this->Files->getValues() as $file) {
             $full = realpath($this->themeBase() . '/' . $file);
             $this->contentDelivery->storeThemeFile($this->StoreIn, $full, $this->ForceResync, strpos($full, '.css') > 0);
         }
     }
     $this->LastSync = date('Y-m-d H:i:s');
     $this->SyncNow = false;
 }
 public function CDNPath($assetPath, $uploadMissing = false, $verify = false)
 {
     $current = $this->currentThemeCdn();
     if ($current && (Director::isLive() || isset($_GET['stage']) && $_GET['stage'] == 'Live')) {
         $store = $current->StoreIn;
         // if we want to upload missing files, verify their existence.
         if (!$verify && $uploadMissing) {
             $verify = true;
         }
         $mtime = @filemtime(Director::baseFolder() . '/' . $assetPath);
         $timedAssetPath = $mtime . '/' . $assetPath;
         $reader = $this->contentService->findReaderFor($store, $timedAssetPath);
         if ($reader && (!$verify || $reader->exists())) {
             return $reader->getURL();
         }
         if ($uploadMissing) {
             if (strpos($assetPath, '.css')) {
                 // if we're a relative path, make absolute
                 $fullPath = $assetPath;
                 if ($assetPath[0] != '/') {
                     $fullPath = Director::baseFolder() . '/' . $assetPath;
                 }
                 if (!file_exists($fullPath)) {
                     return $assetPath;
                 }
                 // upload all references too
                 return $this->contentDelivery->storeThemeFile($store, $fullPath, false, true);
             }
             // otherwise just upload
             $writer = $this->getWriter();
             // otherwise, we need to write the file
             $writer->write(Director::baseFolder() . '/' . $assetPath, $timedAssetPath);
             return $writer->getReader()->getURL();
         }
     }
     return $assetPath;
 }