Closed DuelistRag3 closed 2 years ago
Doubled path is passed after Asset Creation
The problem isn't immediately apparent to me from what you have shared. Does public/assets/themes/default/style.css actually exist or not? Did you follow the Upgrade Guide? Can you share the calling code or a full trace?
EDIT: Ah I see in your image the problem, the full directory is replicated. I will look into this more on desktop.
Looks like it is probably an issue with Windows using a different DIRECTORY_SEPARATOR and it not trimming the relative path:
// Resolve the directory for the active theme
$root = rtrim(config('Assets')->directory, '/ ') . '/';
$directory = $root . trim($theme->path, '/ ');
// Locate all CSS and JSS files in the them path
$files = (new FileCollection())
->addDirectory($directory)
->retainPattern('#(.*)\.css$|(.*)\.js$#i'); // limit to .css and .js files
// Create an Asset from each relative path and add it to the Bundle
foreach ($files as $file) {
$relativePath = str_replace($root, '', $file);
I will try a fix.
A temp fix would be to remove $config->directory in Asset.php from line 94 but thats not a solution at all ^^
public static function createFromPath(string $path): self
{
$config = self::config();
$path = ltrim($path, '/');
$file = new File($config->directory . $path, true);
// Build the URI
$uri = $config->uri . $path;
// Append a timestamp if requested
if ($config->useTimestamps) {
$uri .= '?v=' . $file->getMTime();
}
return self::createFromUri($uri);
}
A temp fix would be to remove $config->directory in Asset.php from line 94 but thats not a solution at all ^^
public static function createFromPath(string $path): self { $config = self::config(); $path = ltrim($path, '/'); $file = new File($config->directory . $path, true); // Build the URI $uri = $config->uri . $path; // Append a timestamp if requested if ($config->useTimestamps) { $uri .= '?v=' . $file->getMTime(); } return self::createFromUri($uri); }
Nvmd it doesnt work
@DuelistRag3 can you try the realpath
branch and see if that PR fixes it for you?
@MGatner Doesn´t seem to work still same error
@DuelistRag3 Pushed another way of doing it, try again?
Nope, still full path is getting handed over
sorry, wrong button ^^
I have another idea. I will also see about adding a Windows Actions runner to automate this testing.
@DuelistRag3 I couldn't get the Windows automation going, mind trying one more time? I think the issue was that the paths weren't matching due to the final directory separator, so I'm handling the comparison with the portion prior to the separator instead.
looks good
looks good
As in, this fixed it??
looks good
As in, this fixed it??
Yes
I freshly installed version 2.0.0-rc.1 with all dependencys and i get File not Found error with a doubled path:
CodeIgniter\Files\Exceptions\FileNotFoundException
File not found: B:\Projects\Web\warriorsweb\public\assets/B:\Projects\Web\warriorsweb\public\assets\themes\default\style.css