Skip to content

Commit e355d44

Browse files
committed
Merge branch '1.x' into 2.x
2 parents f7e7aaf + 344ed7f commit e355d44

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

src/fs/AssetsFs.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@ class AssetsFs extends Fs
1313

1414
public function init(): void
1515
{
16-
$this->useLocalFs = !Module::getInstance()->getConfig()->useAssetCdn;
1716
parent::init();
17+
$this->useLocalFs = !Module::getInstance()->getConfig()->useAssetCdn;
18+
19+
if ($this->useLocalFs) {
20+
$this->baseUrl = $this->getLocalFs()->getRootUrl();
21+
}
1822
}
1923

2024
/**

src/fs/BuildArtifactsFs.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,25 @@
22

33
namespace craft\cloud\fs;
44

5+
use craft\cloud\Helper;
56
use craft\cloud\Module;
67
use League\Uri\Contracts\SegmentedPathInterface;
78

89
class BuildArtifactsFs extends BuildsFs
910
{
1011
public bool $hasUrls = true;
12+
public ?string $localFsPath = '@webroot';
13+
public ?string $localFsUrl = '@web';
1114

1215
public function init(): void
1316
{
14-
$this->baseUrl = Module::getInstance()->getConfig()->artifactBaseUrl;
1517
parent::init();
18+
$this->useLocalFs = !Helper::isCraftCloud();
19+
$this->baseUrl = Module::getInstance()->getConfig()->artifactBaseUrl;
20+
21+
if ($this->useLocalFs && !$this->baseUrl) {
22+
$this->baseUrl = $this->getLocalFs()->getRootUrl();
23+
}
1624
}
1725

1826
public function createBucketPrefix(): SegmentedPathInterface

src/fs/Fs.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ protected function getLocalFs(): Local
7070
$this->localFs = $this->localFs ?? Craft::createObject([
7171
'class' => Local::class,
7272
'hasUrls' => $this->hasUrls,
73-
'path' => $path->toString(),
73+
'path' => $path?->toString(),
7474
'url' => $this->localFsUrl,
7575
]);
7676

@@ -91,10 +91,8 @@ public function getRootUrl(): ?string
9191

9292
public function createUrl(string $path = ''): UriInterface
9393
{
94-
$baseUrl = $this->useLocalFs ? $this->getLocalFs()->getRootUrl() : $this->baseUrl;
95-
96-
if ($baseUrl) {
97-
return Modifier::from($baseUrl)
94+
if ($this->baseUrl) {
95+
return Modifier::from($this->baseUrl)
9896
->appendSegment($this->createPath($path))
9997
->getUri();
10098
}

0 commit comments

Comments
 (0)