Skip to content

Commit 8ffbccf

Browse files
committed
fix: create file storage even if content is empty
1 parent 7459ab2 commit 8ffbccf

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

app/Models/LocalFileVolume.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,21 @@ public function saveStorageOnServer()
8787
$fileVolume->save();
8888
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.');
8989
}
90-
if (! $fileVolume->is_directory && $isDir == 'NOK') {
90+
if ($isDir == 'NOK' && ! $fileVolume->is_directory) {
91+
$chmod = data_get($fileVolume, 'chmod');
92+
$chown = data_get($fileVolume, 'chown');
9193
if ($content) {
9294
$content = base64_encode($content);
93-
$chmod = $fileVolume->chmod;
94-
$chown = $fileVolume->chown;
9595
$commands->push("echo '$content' | base64 -d | tee $path > /dev/null");
96-
$commands->push("chmod +x $path");
97-
if ($chown) {
98-
$commands->push("chown $chown $path");
99-
}
100-
if ($chmod) {
101-
$commands->push("chmod $chmod $path");
102-
}
96+
} else {
97+
$commands->push("touch $path");
98+
}
99+
$commands->push("chmod +x $path");
100+
if ($chown) {
101+
$commands->push("chown $chown $path");
102+
}
103+
if ($chmod) {
104+
$commands->push("chmod $chmod $path");
103105
}
104106
} elseif ($isDir == 'NOK' && $fileVolume->is_directory) {
105107
$commands->push("mkdir -p $path > /dev/null 2>&1 || true");

0 commit comments

Comments
 (0)