Implement persistent trick storages v1 APPLIED

: 1
 Implement persistent trick storages

 1 files changed, 5 insertions(+), 4 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~williewillus/public-inbox/patches/22681/mbox | git am -3
Learn more about email & git

[PATCH] Implement persistent trick storages Export this patch

From: Alwinfy <20421383+Alwinfy@users.noreply.github.com>

 main.rkt | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/main.rkt b/main.rkt
index 314de4e..dc1afba 100755
--- a/main.rkt
+++ b/main.rkt
@@ -283,7 +283,7 @@
  (let ([datum (and~> trick
                      (hash-ref (cdr (storage-info message type)) #f)
                      (with-input-from-bytes read)
                      (with-input-from-string read)
                      (with-handlers ([exn:fail:read? (const #f)]) _))])
    (and (not (eof-object? datum)) datum)))
(define/contract (write-storage trick message type data)
@@ -293,9 +293,9 @@
   (match-let ([(cons limit key) (storage-info message type)])
      (let ([data (with-output-to-bytes (curry write data))])
      (let ([data (with-output-to-string (curry write data))])
         (<= (bytes-length data) limit)
         (<= (string-length data) limit)
           (hash-set! (trick-storage trick) key data)
@@ -372,6 +372,7 @@
  (hasheq 'author (trick-author trick)
          'body (trick-body trick)
          'created (trick-created trick)
          'data (trick-storage trick)
          'invocations (trick-invocations trick)))

(define (json->trick json)
@@ -379,7 +380,7 @@
   (hash-ref json 'author)
   (hash-ref json 'body)
   (hash-ref json 'created)
   (make-hash) ; We purposefully don't save the trick storage due to space limits
   (hash-ref json 'data make-hash)
   (hash-ref json 'invocations)))

(define command-table