diff --git a/nix/ops/solid/builder.sh b/nix/ops/solid/builder.sh index f65cae861..61dfd84b3 100755 --- a/nix/ops/solid/builder.sh +++ b/nix/ops/solid/builder.sh @@ -24,6 +24,7 @@ do sleep 1 done +cp $ARVO/app/lens.hoon ./pier/home/app/ cp $ARVO/lib/pill.hoon ./pier/home/lib/ chmod -R u+rw ./pier/home/lib/ diff --git a/pkg/arvo/app/lens.hoon b/pkg/arvo/app/lens.hoon index 0b84a8aa2..503ed83b3 100644 --- a/pkg/arvo/app/lens.hoon +++ b/pkg/arvo/app/lens.hoon @@ -1,19 +1,25 @@ -/- lens -/+ *server, base64 +/- lens, *sole +/+ base64, *server /= lens-mark /: /===/mar/lens/command /!noun/ =, format |% -:: +move: output effect +:: +lens-out: json or named octet-stream +:: ++$ lens-out + $% [%json =json] + [%mime =mime] + == +:: +move: output effect :: +$ move [bone card] -:: +card: output effect payload +:: +card: output effect payload :: +$ card $% [%connect wire binding:eyre term] [%http-response =http-event:http] [%peer wire dock path] - [%peel wire dock mark path] + [%peer wire dock path] [%poke wire dock poke] [%pull wire dock ~] == @@ -80,16 +86,74 @@ [ost.bow %poke /import [our.bow app.source.com] %import c]~ :: :_ this(job.state (some [ost.bow com])) - [ost.bow %peel /sole [our.bow %dojo] %lens-json /sole]~ + [ost.bow %peer /sole [our.bow %dojo] /sole]~ :: -++ diff-lens-json - |= [=wire jon=json] +++ diff-sole-effect + |= [=wire fec=sole-effect] ^- (quip move _this) - ?~ jon + =/ out + |- ^- (unit lens-out) + =* loop $ + ?+ -.fec + ~ + :: + %tan + %- some + :- %json + %- wall:enjs:format + (turn (flop p.fec) |=(=tank ~(ram re tank))) + :: + %txt + (some %json s+(crip p.fec)) + :: + %sag + %- some + [%mime p.fec (as-octs:mimes:html (jam q.fec))] + :: + %sav + :: XX use +en:base64 or produce %mime a la %sag + :: + %- some + :- %json + %- pairs:enjs:format + :~ file+s+(crip <`path`p.fec>) + data+s+(crip (en-base64:mimes:html q.fec)) + == + :: + %mor + =/ all `(list lens-out)`(murn p.fec |=(a=sole-effect loop(fec a))) + ?~ all ~ + ~| [%multiple-effects all] + ?> ?=(~ t.all) + (some i.all) + == + :: + ?~ out [~ this] ?> ?=(^ job.state) :_ this(job.state ~) - [bone.u.job.state %http-response (json-response:app (json-to-octs jon))]~ + :_ ~ + :+ bone.u.job.state + %http-response + ?- -.u.out + %json + (json-response:app (json-to-octs json.u.out)) + :: + %mime + :* %start + :~ 200 + ['content-type' 'application/octet-stream'] + ?> ?=([@ @ ~] p.mime.u.out) + :- 'content-disposition' + ^- @t + %^ cat 3 + 'attachment; filename=' + (rap 3 '"' i.p.mime.u.out '.' i.t.p.mime.u.out '"' ~) + == + (some q.mime.u.out) + %.y + == + == :: ++ diff-export |= [=wire data=*] @@ -132,6 +196,8 @@ ?> ?=(^ job.state) :_ this :~ [ost.bow %poke /sole [our.bow %dojo] %lens-command com.u.job.state] + :: XX move to +diff-sole-effect? + :: [ost.bow %pull /sole [our.bow %dojo] ~] == :: diff --git a/pkg/arvo/mar/lens/json.hoon b/pkg/arvo/mar/lens/json.hoon deleted file mode 100644 index 7379e3b1d..000000000 --- a/pkg/arvo/mar/lens/json.hoon +++ /dev/null @@ -1,12 +0,0 @@ -:: -:::: /hoon/json/lens/mar - :: -/? 310 -:: -:::: ~fyr - :: -|_ jon/json -++ grab |% ++ noun json - -- -++ grow |% ++ json jon --- -- diff --git a/pkg/arvo/mar/sole/effect.hoon b/pkg/arvo/mar/sole/effect.hoon index 91059fea7..efd99a4a3 100644 --- a/pkg/arvo/mar/sole/effect.hoon +++ b/pkg/arvo/mar/sole/effect.hoon @@ -50,27 +50,6 @@ ++ grow =, enjs |% - ++ lens-json :: json for cli client - ^- ?(~ ^json) :: null = ignore - ?+ -.sef ~ - $tan (wall (turn (flop p.sef) |=(a/tank ~(ram re a)))) - $txt s+(crip p.sef) - $sag - =/ =atom (jam q.sef) - =/ =octs [(met 3 atom) atom] - =/ enc (en:base64 octs) - (pairs file+s+(crip <`path`p.sef>) data+s+enc ~) - $sav - (pairs file+s+(crip <`path`p.sef>) data+s+(crip (en-base64:mimes:html q.sef)) ~) - :: - $mor - =+ all=(turn p.sef |=(a/sole-effect lens-json(sef a))) - =. all (skip all |=(a/^json ?=(~ a))) - ?~ all ~ - ?~ t.all i.all - ~|(multiple-effects+`(list ^json)`all !!) - == - :: ++ json ^- ^json ?+ -.sef diff --git a/pkg/herb/herb b/pkg/herb/herb index ce1d36ed5..30f6834bd 100755 --- a/pkg/herb/herb +++ b/pkg/herb/herb @@ -425,7 +425,12 @@ url = "http://localhost:%s" % PORT r = requests.post(url, data=json.dumps(payload)) -if r.text[0] == '"': +if r.headers.get('content-type') == 'application/octet-stream': + name = r.headers.get('content-disposition').split('filename=',1)[1][1:-1] + with open(name, 'wb') as f: + for block in r.iter_content(1024): + f.write(block) +elif r.text[0] == '"': print r.text[1:-1].encode('utf-8').decode('string_escape') elif r.text[0] == '{': # print r.text diff --git a/pkg/urbit/jets/e/cue.c b/pkg/urbit/jets/e/cue.c index 488cf0226..e2ad70998 100644 --- a/pkg/urbit/jets/e/cue.c +++ b/pkg/urbit/jets/e/cue.c @@ -38,10 +38,14 @@ _cue_push(c3_ys mov, // (off==0 means we're on a north road) // if ( 0 == off ) { - c3_assert(u3R->cap_p > u3R->hat_p); + if( !(u3R->cap_p > u3R->hat_p) ) { + u3m_bail(c3__meme); + } } else { - c3_assert(u3R->cap_p < u3R->hat_p); + if( !(u3R->cap_p < u3R->hat_p) ) { + u3m_bail(c3__meme); + } } cueframe* fam_u = u3to(cueframe, u3R->cap_p + off); diff --git a/pkg/urbit/jets/e/jam.c b/pkg/urbit/jets/e/jam.c index 5869d657b..37594345d 100644 --- a/pkg/urbit/jets/e/jam.c +++ b/pkg/urbit/jets/e/jam.c @@ -138,8 +138,25 @@ _jam_buf_atom(_jam_buf* buf_u, u3_noun a) else { _jam_buf_chop(&buf_u, 2, 1); *top = u3t(a); - u3R->cap_p += mov; + + // XX disabled for performance + // may be unnecessary, u3h_put calls u3r_mug, + // which uses and checks the stack + // +#if 0 + if ( 0 == off ) { + if( !(u3R->cap_p > u3R->hat_p) ) { + u3m_bail(c3__meme); + } + } + else { + if( !(u3R->cap_p < u3R->hat_p) ) { + u3m_bail(c3__meme); + } + } +#endif + top = u3to(u3_noun, u3R->cap_p + off); *top = u3h(a); } diff --git a/pkg/urbit/noun/allocate.c b/pkg/urbit/noun/allocate.c index 1a1476b29..299f5bc60 100644 --- a/pkg/urbit/noun/allocate.c +++ b/pkg/urbit/noun/allocate.c @@ -586,8 +586,13 @@ u3a_push(c3_w len_w) top -= len_w; cur = top; u3p(void) cap_p = u3R->cap_p = u3of(void, top); - c3_assert(cap_p < u3R->mat_p); - c3_assert(cap_p > u3R->hat_p); + + if( !( cap_p < u3R->mat_p && + cap_p > u3R->hat_p ) ) + { + u3m_bail(c3__meme); + } + return cur; } else { @@ -595,8 +600,13 @@ u3a_push(c3_w len_w) top += len_w; u3R->cap_p = u3of(void, top); u3p(void) cap_p = u3R->cap_p = u3of(void, top); - c3_assert(cap_p > u3R->mat_p); - c3_assert(cap_p < u3R->hat_p); + + if( !( cap_p > u3R->mat_p && + cap_p < u3R->hat_p ) ) + { + u3m_bail(c3__meme); + } + return cur; } } diff --git a/pkg/urbit/noun/nock.c b/pkg/urbit/noun/nock.c index a08034db6..01ec70d00 100644 --- a/pkg/urbit/noun/nock.c +++ b/pkg/urbit/noun/nock.c @@ -1345,6 +1345,22 @@ static inline void _n_push(c3_ys mov, c3_ys off, u3_noun a) { u3R->cap_p += mov; + + // XX stack sanity-check disabled for performance + // +#if 0 + if ( 0 == off ) { + if( !(u3R->cap_p > u3R->hat_p) ) { + u3m_bail(c3__meme); + } + } + else { + if( !(u3R->cap_p < u3R->hat_p) ) { + u3m_bail(c3__meme); + } + } +#endif + u3_noun* p = u3to(u3_noun, u3R->cap_p + off); *p = a; } diff --git a/pkg/urbit/noun/retrieve.c b/pkg/urbit/noun/retrieve.c index f2a653264..42dc35dbf 100644 --- a/pkg/urbit/noun/retrieve.c +++ b/pkg/urbit/noun/retrieve.c @@ -1597,10 +1597,14 @@ _mug_push(c3_ys mov, // (off==0 means we're on a north road) // if ( 0 == off ) { - c3_assert(u3R->cap_p > u3R->hat_p); + if( !(u3R->cap_p > u3R->hat_p) ) { + u3m_bail(c3__meme); + } } else { - c3_assert(u3R->cap_p < u3R->hat_p); + if( !(u3R->cap_p < u3R->hat_p) ) { + u3m_bail(c3__meme); + } } mugframe* fam_u = u3to(mugframe, u3R->cap_p + off);