Fix styling
This commit is contained in:

committed by
github-actions[bot]
![github-actions[bot]](/assets/img/avatar_default.png)
parent
41fb6a1fc9
commit
d86274cc37
@@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
class LocalFileVolume extends BaseModel
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
protected static function booted()
|
||||
@@ -16,10 +17,12 @@ class LocalFileVolume extends BaseModel
|
||||
dispatch(new \App\Jobs\ServerStorageSaveJob($fileVolume));
|
||||
});
|
||||
}
|
||||
|
||||
public function service()
|
||||
{
|
||||
return $this->morphTo('resource');
|
||||
}
|
||||
|
||||
public function deleteStorageOnServer()
|
||||
{
|
||||
$isService = data_get($this->resource, 'service');
|
||||
@@ -31,15 +34,17 @@ class LocalFileVolume extends BaseModel
|
||||
$server = $this->resource->destination->server;
|
||||
}
|
||||
$commands = collect([
|
||||
"cd $workdir"
|
||||
"cd $workdir",
|
||||
]);
|
||||
$fs_path = data_get($this, 'fs_path');
|
||||
if ($fs_path && $fs_path != '/' && $fs_path != '.' && $fs_path != '..') {
|
||||
$commands->push("rm -rf $fs_path");
|
||||
}
|
||||
ray($commands);
|
||||
|
||||
return instant_remote_process($commands, $server);
|
||||
}
|
||||
|
||||
public function saveStorageOnServer()
|
||||
{
|
||||
$isService = data_get($this->resource, 'service');
|
||||
@@ -52,7 +57,7 @@ class LocalFileVolume extends BaseModel
|
||||
}
|
||||
$commands = collect([
|
||||
"mkdir -p $workdir > /dev/null 2>&1 || true",
|
||||
"cd $workdir"
|
||||
"cd $workdir",
|
||||
]);
|
||||
$is_directory = $this->is_directory;
|
||||
if ($is_directory) {
|
||||
@@ -69,16 +74,16 @@ class LocalFileVolume extends BaseModel
|
||||
$content = data_get($fileVolume, 'content');
|
||||
if ($path->startsWith('.')) {
|
||||
$path = $path->after('.');
|
||||
$path = $workdir . $path;
|
||||
$path = $workdir.$path;
|
||||
}
|
||||
$isFile = instant_remote_process(["test -f $path && echo OK || echo NOK"], $server);
|
||||
$isDir = instant_remote_process(["test -d $path && echo OK || echo NOK"], $server);
|
||||
if ($isFile == 'OK' && $fileVolume->is_directory) {
|
||||
throw new \Exception("The following file is a file on the server, but you are trying to mark it as a directory. Please delete the file on the server or mark it as directory.");
|
||||
} else if ($isDir == 'OK' && !$fileVolume->is_directory) {
|
||||
throw new \Exception("The following file is a directory on the server, but you are trying to mark it as a file. <br><br>Please delete the directory on the server or mark it as directory.");
|
||||
throw new \Exception('The following file is a file on the server, but you are trying to mark it as a directory. Please delete the file on the server or mark it as directory.');
|
||||
} elseif ($isDir == 'OK' && ! $fileVolume->is_directory) {
|
||||
throw new \Exception('The following file is a directory on the server, but you are trying to mark it as a file. <br><br>Please delete the directory on the server or mark it as directory.');
|
||||
}
|
||||
if (!$fileVolume->is_directory && $isDir == 'NOK') {
|
||||
if (! $fileVolume->is_directory && $isDir == 'NOK') {
|
||||
if ($content) {
|
||||
$content = base64_encode($content);
|
||||
$chmod = $fileVolume->chmod;
|
||||
@@ -92,9 +97,10 @@ class LocalFileVolume extends BaseModel
|
||||
$commands->push("chmod $chmod $path");
|
||||
}
|
||||
}
|
||||
} else if ($isDir == 'NOK' && $fileVolume->is_directory) {
|
||||
} elseif ($isDir == 'NOK' && $fileVolume->is_directory) {
|
||||
$commands->push("mkdir -p $path > /dev/null 2>&1 || true");
|
||||
}
|
||||
|
||||
return instant_remote_process($commands, $server);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user