3 ms·
This gives me an idea. Use git to manage versions of the static files. Use [git worktree][1] to have multiple separate working trees in different directories.
by MathMonkeyMan 2y ago
This gives me an idea.
Use git to manage versions of the static files.
Use [git worktree][1] to have multiple separate working trees in different directories.
Use [openat()][2] in your app whenever serving a request for a static file. On each request, open the directory, i.e. `/var/www/mysite.com`, and then use `openat()` with the directory's file descriptor when looking up any files under that directory.
`/var/www/mysite.com` is a symbolic link to some working tree.
When modifying the site, make modifications to the git repository. Then check out the modified working tree into a new directory.
Create a symbolic link to the new directory and `mv` (rename) it to `/var/www/mysite.com`.
Then some time later, `rm -r` the old working tree.
[1]: https://git-scm.com/docs/git-worktree https://git-scm.com/docs/git-worktree
[2]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/open.html https://pubs.opengroup.org/onlinepubs/9799919799/functions/o...
- mistrial9 2y ago> Use git to manage versions of the static files bad match -- git stores every version in the history forever. Do you really need every revision of a binary file, completely duplicated? big files, more bad
- MathMonkeyMan 2y agoHm, good point. I suppose you could use [more git commands][1] to enforce a "nothing older than N commits" policy. But now the solution lacks that dead simple allure. [1]: https://www.reddit.com/r/git/comments/wk2kqy/delete_files_under_master_branch_which_is_older/ https://www.reddit.com/r/git/comments/wk2kqy/delete_files_un...