public function createLocalIfNeeded()
    {
        if ($this->owner->CloudStatus === 'Live') {
            $bucket = $this->getCloudBucket();
            if ($bucket && $bucket->isLocalCopyEnabled()) {
                if (!file_exists($this->owner->getFullPath()) || $this->containsPlaceholder()) {
                    try {
                        $this->downloadFromCloud();
                    } catch (Exception $e) {
                        // I'm not sure what the correct behaviour is here
                        // Pretty sure it'd be better to have a broken image
                        // link than a 500 error though.
                        CloudAssets::inst()->getLogger()->error("CloudAssets: Failed bucket download: " . $e->getMessage() . " for " . $this->owner->getFullPath());
                    }
                }
            } else {
                if (!file_exists($this->owner->getFullPath())) {
                    $this->convertToPlaceholder();
                }
            }
        }
    }
public function createLocalIfNeeded()
    {
        if ($this->owner->CloudStatus === 'Live') {
            $bucket = $this->getCloudBucket();
            if ($bucket && $bucket->isLocalCopyEnabled()) {
                if (!file_exists($this->owner->getFullPath()) || $this->containsPlaceholder()) {
                    try {
                        $this->downloadFromCloud();
                    } catch (Exception $e) {
                        // I'm not sure what the correct behaviour is here
                        // Pretty sure it'd be better to have a broken image
                        // link than a 500 error though.
                        CloudAssets::inst()->getLogger()->error("CloudAssets: Failed bucket download: " . $e->getMessage() . " for " . $this->owner->getFullPath());
                    }
                }
            } else {
                if (!file_exists($this->owner->getFullPath())) {
                    $this->convertToPlaceholder();
                }
            }
        }
    }
public function createLocalIfNeeded ( ) { if ( $ this -> owner -> CloudStatus === 'Live' ) { $ bucket = $ this -> getCloudBucket ( ) ; if ( $ bucket && $ bucket -> isLocalCopyEnabled ( ) ) { if ( ! file_exists ( $ this -> owner -> getFullPath ( ) ) || $ this -> containsPlaceholder ( ) ) { try { $ this -> downloadFromCloud ( ) ; } catch ( Exception $ e ) { // I'm not sure what the correct behaviour is here // Pretty sure it'd be better to have a broken image // link than a 500 error though. CloudAssets :: inst ( ) -> getLogger ( ) -> error ( "CloudAssets: Failed bucket download: " . $ e -> getMessage ( ) . " for " . $ this -> owner -> getFullPath ( ) ) ; } } } else { if ( ! file_exists ( $ this -> owner -> getFullPath ( ) ) ) { $ this -> convertToPlaceholder ( ) ; } } } }
If the file is present in the database and the cloud but not
locally, create a placeholder for it. This can happen in a lot
of cases such as load balanced servers and local development.
If the file is present in the database and the cloud but not locally create a placeholder for it . This can happen in a lot of cases such as load balanced servers and local development .