schovi / baked_file_system

Virtual File System for Crystal language. Embedding your assets into final binary.
MIT License
177 stars 18 forks source link

Symlink Problem when reading from local shard #5

Closed jasonl99 closed 7 years ago

jasonl99 commented 7 years ago

I'm using baked_file_system to serve files from a shard if they are not present on the app. So I use BakedFileStorage.load("../lib/foo/public") for example to load from a shard named foo.

The shards.yml spec allows you to specify sources of github, git, and path. shards install/update seems to create a symlink when you use path: in the yml file, which is great, because it's constantly the current version if you are testing the shard within an app (you don't have to constantly be running shards update

However, for some reason, BakeFileStorage isn't reading symlinked files. So if my shard.yml file looks like this:

dependences:
  foo:
     path: /home/jason/crystal/foo

and run the following code:

class FooFiles
  BakedFileStorage.load("../lib/foo/public")
end
FooFiles.files.size  # 0

But if I delete the symlinked lib/foo directory and actually copy over the /home/crystal/foo project into the lib folder, it works as expected and my files are there.

jasonl99 commented 7 years ago

Urg. Please tag me with the "original poster is an idiot" marker. I didn't even realize that this already took into account where it was installed.

I have a class under src/storage/public_storage.cr so the correct path to get to the public directory is this: BakedFileSystem.load("../../public") if anyone else runs into something similar.