b374k
m1n1 1.01
Apache/2.4.41 (Ubuntu)
Linux vmi616275.contaboserver.net 5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64
uid=33(www-data) gid=33(www-data) groups=33(www-data)
server ip : 62.171.164.128 | your ip : 127.0.0.1
safemode OFF
 >  / home / a / home / dev2.destoffenstraat.com / vendor / magento / framework / View / Asset /
Filename/home/a/home/dev2.destoffenstraat.com/vendor/magento/framework/View/Asset/LockerProcess.php
Size3.1 kb
Permissionrw-r--r--
Ownerroot : root
Create time21-Aug-2025 12:26
Last modified07-Jan-2021 21:08
Last accessed24-Aug-2025 01:22
Actionsedit | rename | delete | download (gzip)
Viewtext | code | image
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Framework\View\Asset;

use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\App\State;
use Magento\Framework\Exception\FileSystemException;
use Magento\Framework\Filesystem;
use Magento\Framework\Filesystem\Directory\WriteInterface;

/**
* Class LockerProcess
*/
class LockerProcess implements LockerProcessInterface
{
/**
* File extension lock
*/
const LOCK_EXTENSION = '.lock';

/**
* Max execution (locking) time for process (in seconds)
*/
const MAX_LOCK_TIME = 30;

/**
* @var Filesystem
*/
private $filesystem;

/**
* @var string
*/
private $lockFilePath;

/**
* @var WriteInterface
*/
private $tmpDirectory;

/**
* @var State
*/
private $state;

/**
* Constructor
*
* @param Filesystem $filesystem
*/
public function __construct(Filesystem $filesystem)
{
$this->filesystem = $filesystem;
}

/**
* @inheritdoc
*/
public function lockProcess($lockName)
{
if ($this->getState()->getMode() === State::MODE_PRODUCTION || PHP_SAPI === 'cli') {
return;
}

$this->tmpDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
$this->lockFilePath = $this->getFilePath($lockName);

while ($this->isProcessLocked()) {
usleep(1000);
}

$this->tmpDirectory->writeFile($this->lockFilePath, time());
}

/**
* @inheritdoc
*
* @throws FileSystemException
*/
public function unlockProcess()
{
if ($this->getState()->getMode() === State::MODE_PRODUCTION || PHP_SAPI === 'cli') {
return;
}

$this->tmpDirectory->delete($this->lockFilePath);
}

/**
* Check whether generation process has already locked
*
* @return bool
*/
private function isProcessLocked()
{
if ($this->tmpDirectory->isExist($this->lockFilePath)) {
try {
$lockTime = (int)$this->tmpDirectory->readFile($this->lockFilePath);
if ((time() - $lockTime) >= self::MAX_LOCK_TIME) {
$this->tmpDirectory->delete($this->lockFilePath);

return false;
}
} catch (FileSystemException $e) {
return false;
}

return true;
}

return false;
}

/**
* Get path to lock file
*
* @param string $name
*
* @return string
*/
private function getFilePath($name)
{
return DirectoryList::TMP . DIRECTORY_SEPARATOR . $name . self::LOCK_EXTENSION;
}

/**
* Get State object
*
* @return State
*
* @deprecated 100.1.1
*/
private function getState()
{
if (null === $this->state) {
$this->state = ObjectManager::getInstance()->get(State::class);
}
return $this->state;
}
}