I’m definitely missing something! I physically delete the uploaded file, I Shift-reload, I clear browser cache, I use incognito mode, run through another browser, and I can still serve the uploaded image by its direct link! I restart the phoenix server. It can still be served What am I missing?
My example repo on which I’m experiencing this.
Alright, I see. Files actually appear at _build/dev/lib/project/priv/uploads
, as long as local in priv/uploads
. So if I delete them from priv/uploads
, this action is not propagated to the _build/dev
. That might also explain my previous struggles with the files only showing after right click reload. Scratching my head
I’m documenting this because I couldn’t find an answer anywhere else.
What happens is that, under Windows, if you are running mix phx.server
without elevated privileges upon initial build, or every time after erasing _build/<your_app>
folder, the warning is issued:
[warning] Phoenix is unable to create symlinks. Phoenix’ code reloader will run considerably faster if symlinks are allowed. On Windows, the lack of symlinks may even cause empty assets to be served. Luckily, you can address this issue by starting your Windows terminal at least once with “Run as Administrator” and then running your Phoenix application.
It sounds a bit obscure, but what it actually means is that the _build/<your_app>/priv
becomes a copy. This is what it looks like:
How exactly it is maintained is a little mystery, a black box. But it certainly cannot be a “wait until I finish” type of thing. This copy is not maintained completely as a clone of the source priv
. In fact, it leaves erased from the source priv
files behind, in my case it was uploads that I killed from within the app as discarded. Not sure if that kind of cloning is an expected behavior, but this it what it is and this is causing the files to continue being served, and made me freak out .
Now when we run the app under Admin privilege - once, as instructed - a “symlink” is in fact generated, _build/<your_app>/priv
:
Now whenever I delete the files in my priv/upload
, either by hand, or through the app, whatever is served is mirrored by the filesystem.
Thanks for listening!
3 Likes