objective categorical abstract machine language personal data server
65
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix db creation

futurGH df56e780 db88de6c

+20 -10
+3 -1
pegasus/lib/api/repo/createAccount.ml
··· 92 92 Data_store.create_actor ~did ~handle:input.handle ~email:input.email 93 93 ~password:input.password ~signing_key:sk_priv_mk ctx.db 94 94 in 95 - let%lwt _ = User_store.connect ~create:true ~write:true did in 95 + let () = 96 + Util.mkfile_p (Util.Constants.user_db_filepath did) ~perm:0o644 97 + in 96 98 let%lwt repo = Repository.load ~write:true ~ds:ctx.db did in 97 99 let%lwt _ = Repository.put_initial_commit repo in 98 100 let%lwt _ =
+1 -1
pegasus/lib/data_store.ml
··· 102 102 %string{signing_key}, 103 103 %Json{preferences}, 104 104 %int{created_at} 105 - ); 105 + ) 106 106 |sql}] 107 107 108 108 let get_actor_by_identifier id =
+2 -1
pegasus/lib/user_store.ml
··· 81 81 id INTEGER PRIMARY KEY CHECK (id = 0), 82 82 cid TEXT NOT NULL, 83 83 data BLOB NOT NULL 84 - ); 84 + ) 85 85 |sql}] 86 86 () conn 87 87 ··· 448 448 (Util.Constants.user_blobs_location t.did) 449 449 (Cid.to_string cid) 450 450 in 451 + let () = Util.mkfile_p file ~perm:0o644 in 451 452 let _ = Out_channel.with_open_bin file Out_channel.output_bytes data in 452 453 Util.use_pool t.db @@ Queries.put_blob cid mimetype 453 454
+14 -7
pegasus/lib/util.ml
··· 3 3 Core.Filename.to_absolute_exn Env.data_dir 4 4 ~relative_to:(Core_unix.getcwd ()) 5 5 6 - let pegasus_db_location = 7 - "sqlite3://" ^ Filename.concat data_dir "pegasus.db" |> Uri.of_string 6 + let pegasus_db_filepath = Filename.concat data_dir "pegasus.db" 7 + 8 + let pegasus_db_location = "sqlite3://" ^ pegasus_db_filepath |> Uri.of_string 9 + 10 + let user_db_filepath did = 11 + let dirname = Filename.concat data_dir "store" in 12 + let filename = Str.global_replace (Str.regexp ":") "_" did in 13 + Filename.concat dirname filename ^ ".db" 8 14 9 15 let user_db_location did = 10 - did 11 - |> Str.global_replace (Str.regexp ":") "_" 12 - |> (Filename.concat data_dir "store" |> Filename.concat) 13 - |> Format.sprintf "sqlite3://%s.db" 14 - |> Uri.of_string 16 + "sqlite3://" ^ user_db_filepath did |> Uri.of_string 15 17 16 18 let user_blobs_location did = 17 19 did ··· 196 198 Uri.add_query_params' db_uri 197 199 [("create", string_of_bool create); ("write", string_of_bool write)] 198 200 in 201 + Dream.log "%s" (Uri.to_string uri) ; 199 202 match 200 203 Caqti_lwt_unix.connect_pool 201 204 ~post_connect:(fun conn -> Lwt_result.ok @@ _init_connection conn) ··· 304 307 Error (Errors.InvalidRequestError ("InvalidHandle", "handle too long")) 305 308 | _ -> 306 309 Ok () 310 + 311 + let mkfile_p path ~perm = 312 + Core_unix.mkdir_p (Filename.dirname path) ~perm:0o644 ; 313 + Core_unix.openfile ~mode:[O_CREAT; O_WRONLY] ~perm path |> Core_unix.close