Integrate locking into the dep update process
This commit is contained in:
Родитель
6b58f91d9d
Коммит
a5afa11cff
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace SDK\Build\Dependency;
|
namespace SDK\Build\Dependency;
|
||||||
|
|
||||||
use SDK\{Config, Cache, Exception, FileOps};
|
use SDK\{Config, Cache, Exception, FileOps, Lock};
|
||||||
|
|
||||||
class Manager
|
class Manager
|
||||||
{
|
{
|
||||||
|
@ -39,7 +39,7 @@ class Manager
|
||||||
|
|
||||||
public function updatesAvailable() : bool
|
public function updatesAvailable() : bool
|
||||||
{/*{{{*/
|
{/*{{{*/
|
||||||
return $this->series->updatesAvailable();
|
return $this->series->updatesAvailable() || !file_exists(Config::getDepsLocalPath());
|
||||||
}/*}}}*/
|
}/*}}}*/
|
||||||
|
|
||||||
/* FIXME implement rollback */
|
/* FIXME implement rollback */
|
||||||
|
@ -50,6 +50,14 @@ class Manager
|
||||||
$msg .= "No updates are available";
|
$msg .= "No updates are available";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$lock = new Lock(Config::getDepsLocalPath(), false);
|
||||||
|
if (!$lock->exclusive()) {
|
||||||
|
$msg .= "Another process is updating same dependency path. I'm just going to wait for it to finish and then exit.";
|
||||||
|
$lock->exclusive(true);
|
||||||
|
unset($lock);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$series_data = $this->series->getData();
|
$series_data = $this->series->getData();
|
||||||
|
@ -86,10 +94,16 @@ class Manager
|
||||||
|
|
||||||
/* This is fine, it's gonna be on the same drive. */
|
/* This is fine, it's gonna be on the same drive. */
|
||||||
if (!$this->mv($this->path, $new_path)) {
|
if (!$this->mv($this->path, $new_path)) {
|
||||||
|
if (!$force) {
|
||||||
|
unset($lock);
|
||||||
|
}
|
||||||
throw new Exception("Unable to rename '{$this->path}' to '$new_path'");
|
throw new Exception("Unable to rename '{$this->path}' to '$new_path'");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!$this->rm($this->path)) {
|
if (!$this->rm($this->path)) {
|
||||||
|
if (!$force) {
|
||||||
|
unset($lock);
|
||||||
|
}
|
||||||
throw new Exception("Unable to remove the current dependency dir at '{$this->path}'");
|
throw new Exception("Unable to remove the current dependency dir at '{$this->path}'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,6 +111,9 @@ class Manager
|
||||||
$up = dirname($this->path);
|
$up = dirname($this->path);
|
||||||
if (!file_exists($up)) {
|
if (!file_exists($up)) {
|
||||||
if (!$this->md($up)) {
|
if (!$this->md($up)) {
|
||||||
|
if (!$force) {
|
||||||
|
unset($lock);
|
||||||
|
}
|
||||||
throw new Exception("Unable to create '{$this->path}'");
|
throw new Exception("Unable to create '{$this->path}'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,6 +135,10 @@ class Manager
|
||||||
} else {
|
} else {
|
||||||
$msg .= "No backup was created.";
|
$msg .= "No backup was created.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$force) {
|
||||||
|
unset($lock);
|
||||||
|
}
|
||||||
}/*}}}*/
|
}/*}}}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче