Compare commits

..

3 commits

Author SHA1 Message Date
liquidex c87662419a fix branches 2024-11-23 22:19:26 +01:00
liquidex 8461812935 make applying edits work correctly
turns out they weren't quite working due to me being a dummy and not awaiting my asyncs
2024-11-23 22:18:21 +01:00
liquidex 55f12caf22 mention vfs refactor in changelog because it has some user-facing consequences (lack of version history) 2024-11-23 22:12:38 +01:00
4 changed files with 54 additions and 3 deletions

View file

@ -1,8 +1,10 @@
% id = "01JDDE33S6T32XGTM21T6581Z5"
- overcoming [fear of the unknown][page:philosophy/fear-of-the-unknown], episode 1.
- overthinking my [furry][page:philosophy/furry] self again.
my heart is pounding.
% id = "01JDDE33S66AG2JQCBQT3GYACX"
- I play Blue Calx.
- as the first notes come in, I sense warm feeling, as if being hugged by someone.
@ -31,6 +33,8 @@
- the metronome starts fading away.
it really is going to be okay.
% id = "01JDDE33S606YTH6EXW70Y6YTB"
- thank you, Richard.
% id = "01JDDE33S61ZHW39ZZ03STAF6Z"
- my heart's still pounding, but hearing this track made me feel a little better about myself.

View file

@ -1,5 +1,36 @@
%% title = "what's going on inside the house? (a changelog)"
% id = "01JDDE4YE6RT06B7EC1R7KBTJH"
- *revision 13:* [virtual insanity](https://www.youtube.com/watch?v=4JkIs37a2JE){.secret}
% id = "01JDDE4YE6NQBA6Q0TJDEFHYQK"
- removed version history :cry:
% id = "01JDDE4YE6A70Q8WT8N3MVTK1G"
+ the quality of this feature was too low for my standards.
this was caused by the treehouse's codebase being one giant pile of spaghetti, onto which bolting a version history feature only caused more havoc :oh:
% id = "01JDDE4YE6Q6NY2NT12HY4Y510"
- if you've ever run across broken branch links, you can thank version history jank for that.
% id = "01JDDE4YE6VY4FWQ21H7X2VGQ4"
- I refactored treehouse (the software) to no longer generate files upfront!
instead, there's a _virtual file system_ from which the web server sources files.
% id = "01JDDE4YE6K43DMZZ9GGNYT5G6"
- this virtual file system, or at least [the part that assembles the page as it's served to you][vfs target], generates pages lazily---which causes my dev experience to be _faaaaaaaAAAAAAAAAAAAAAAAAAAA_
st
[vfs target]: https://src.liquidev.net/liquidex/treehouse/src/commit/0f8d05adebfe323908be487187d9afe6aaa2df36/crates/treehouse/src/generate.rs#L511
% id = "01JDDE4YE6RQH27JGPN28ZAJYC"
+ this generally doesn't mean anything for you, but for me... man, does the treehouse feel fast to edit now!
% id = "01JDDE4YE61YX8TC6NH1F0F2HF"
- generating all the page versions upfront meant I needed to wait over a second for the page to refresh, which made editing any minute details _really_ painful.
imagine I did all the previous layout refurnishment with that...
% id = "01JBWHXTMC7GZEMTH2WT7TN1GT"
- *revision 12:* refurnishment

View file

@ -1,17 +1,24 @@
%% title = "treehouse virtual file system design"
% id = "01JDDE33S14N7HWB2W1Z603K94"
- notes on the design; this is not an actual listing of the virtual file system
% id = "01JDDE33S1CXBQ9EB4ENYG3JNP"
- `content` - `GitDir(".", "content")`
% id = "01JDDE33S1G9B80CJDM09TG5MJ"
- `GitDir` is a special filesystem which makes all files have subpaths with commit data sourced from git.
their entries are ordered by how new/old a commit is
% id = "01JDDE33S11P6NP1NNMVF6EX52"
- `inner/<commit>` - contains the file content and a revision info fork
% id = "01JDDE33S1EK8JKHKVGXSR46HB"
- `inner/latest` - same but for the latest revision, if applicable.
this may be the working tree
% id = "01JDDE33S1X9GT32HCZE12455A"
- `template` - `PhysicalDir("template")`
% id = "01JDDE33S14FEG7XHBRCN3H8WM"
- `static` - `PhysicalDir("static")`

View file

@ -1,6 +1,6 @@
use std::{error::Error, fmt, future::Future, path::PathBuf};
use log::{error, info};
use log::{debug, error, info};
use tokio::task::JoinSet;
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord)]
@ -36,26 +36,35 @@ impl Edit {
pub fn apply(self) -> impl Future<Output = Result<(), ApplyFailed>> + Send {
async {
match self {
Edit::NoOp => (),
Edit::NoOp => debug!("no op edit"),
Edit::Write(edit_path, content) => {
tokio::fs::write(&edit_path.path, &content)
.await
.inspect_err(|err| error!("write to {edit_path:?} failed: {err:?}"))
.map_err(|_| ApplyFailed)?;
debug!("wrote {} bytes to {edit_path:?}", content.len())
}
Edit::Seq(vec) => {
debug!("begin sequence of {} edits", vec.len());
for edit in vec {
Box::pin(edit.apply()).await?;
}
debug!("end sequence");
}
Edit::All(vec) => {
debug!("begin parallel {} edits", vec.len());
let mut set = JoinSet::new();
for edit in vec {
set.spawn(edit.apply());
}
while let Some(result) = set.try_join_next() {
while let Some(result) = set.join_next().await {
result.map_err(|_| ApplyFailed)??;
}
debug!("end parallel");
}
Edit::Dry(edit) => edit.dry(),
}